361 // Set the number of tasks to be claimed to t. As above, 362 // should be called before the tasks start but it is safe 363 // to call this once a task is running provided all threads 364 // agree on the number of tasks. 365 void set_n_tasks(uint t) { _n_tasks = t; } 366 367 // Returns false if the next task in the sequence is unclaimed, 368 // and ensures that it is claimed. Will set t to be the index 369 // of the claimed task in the sequence. Will return true if 370 // the task cannot be claimed and there are none left to claim. 371 bool is_task_claimed(uint& t); 372 373 // The calling thread asserts that it has attempted to claim 374 // all the tasks it possibly can in the sequence. Every thread 375 // claiming tasks must promise call this. Returns true if this 376 // is the last thread to complete so that the thread can perform 377 // cleanup if necessary. 378 bool all_tasks_completed(); 379 }; 380 381 // Represents a set of free small integer ids. 382 class FreeIdSet : public CHeapObj<mtGC> { 383 enum { 384 end_of_list = UINT_MAX, 385 claimed = UINT_MAX - 1 386 }; 387 388 uint _size; 389 Monitor* _mon; 390 391 uint* _ids; 392 uint _hd; 393 uint _waiters; 394 uint _claimed; 395 396 public: 397 FreeIdSet(uint size, Monitor* mon); 398 ~FreeIdSet(); 399 400 // Returns an unclaimed parallel id (waiting for one to be released if 401 // necessary). 402 uint claim_par_id(); 403 404 void release_par_id(uint id); 405 }; 406 407 #endif // SHARE_VM_GC_SHARED_WORKGROUP_HPP | 361 // Set the number of tasks to be claimed to t. As above, 362 // should be called before the tasks start but it is safe 363 // to call this once a task is running provided all threads 364 // agree on the number of tasks. 365 void set_n_tasks(uint t) { _n_tasks = t; } 366 367 // Returns false if the next task in the sequence is unclaimed, 368 // and ensures that it is claimed. Will set t to be the index 369 // of the claimed task in the sequence. Will return true if 370 // the task cannot be claimed and there are none left to claim. 371 bool is_task_claimed(uint& t); 372 373 // The calling thread asserts that it has attempted to claim 374 // all the tasks it possibly can in the sequence. Every thread 375 // claiming tasks must promise call this. Returns true if this 376 // is the last thread to complete so that the thread can perform 377 // cleanup if necessary. 378 bool all_tasks_completed(); 379 }; 380 381 #endif // SHARE_VM_GC_SHARED_WORKGROUP_HPP |