330 SubTasksDone(uint n); |
330 SubTasksDone(uint n); |
331 |
331 |
332 // True iff the object is in a valid state. |
332 // True iff the object is in a valid state. |
333 bool valid(); |
333 bool valid(); |
334 |
334 |
335 // Returns "false" if the task "t" is unclaimed, and ensures that task is |
335 // Attempt to claim the task "t", returning true if successful, |
336 // claimed. The task "t" is required to be within the range of "this". |
336 // false if it has already been claimed. The task "t" is required |
337 bool is_task_claimed(uint t); |
337 // to be within the range of "this". |
|
338 bool try_claim_task(uint t); |
338 |
339 |
339 // The calling thread asserts that it has attempted to claim all the |
340 // The calling thread asserts that it has attempted to claim all the |
340 // tasks that it will try to claim. Every thread in the parallel task |
341 // tasks that it will try to claim. Every thread in the parallel task |
341 // must execute this. (When the last thread does so, the task array is |
342 // must execute this. (When the last thread does so, the task array is |
342 // cleared.) |
343 // cleared.) |
389 // should be called before the tasks start but it is safe |
390 // should be called before the tasks start but it is safe |
390 // to call this once a task is running provided all threads |
391 // to call this once a task is running provided all threads |
391 // agree on the number of tasks. |
392 // agree on the number of tasks. |
392 void set_n_tasks(uint t) { _n_tasks = t; } |
393 void set_n_tasks(uint t) { _n_tasks = t; } |
393 |
394 |
394 // Returns false if the next task in the sequence is unclaimed, |
395 // Attempt to claim the next unclaimed task in the sequence, |
395 // and ensures that it is claimed. Will set t to be the index |
396 // returning true if successful, with t set to the index of the |
396 // of the claimed task in the sequence. Will return true if |
397 // claimed task. Returns false if there are no more unclaimed tasks |
397 // the task cannot be claimed and there are none left to claim. |
398 // in the sequence. |
398 bool is_task_claimed(uint& t); |
399 bool try_claim_task(uint& t); |
399 |
400 |
400 // The calling thread asserts that it has attempted to claim |
401 // The calling thread asserts that it has attempted to claim |
401 // all the tasks it possibly can in the sequence. Every thread |
402 // all the tasks it possibly can in the sequence. Every thread |
402 // claiming tasks must promise call this. Returns true if this |
403 // claiming tasks must promise call this. Returns true if this |
403 // is the last thread to complete so that the thread can perform |
404 // is the last thread to complete so that the thread can perform |