@@ -305,24 +305,18 @@ class WorkGangBarrierSync : public StackObj {
305305class SubTasksDone : public CHeapObj <mtInternal> {
306306 volatile bool * _tasks;
307307 uint _n_tasks;
308- volatile uint _threads_completed;
309308
310- // Set all tasks to unclaimed.
311- void clear ();
312-
313- void all_tasks_completed_impl (uint n_threads, uint skipped[], size_t skipped_size);
309+ // make sure verification logic is run exactly once to avoid duplicate assertion failures
310+ DEBUG_ONLY (volatile bool _verification_done = false ;)
311+ void all_tasks_claimed_impl (uint skipped[], size_t skipped_size) NOT_DEBUG_RETURN;
314312
315313 NONCOPYABLE (SubTasksDone);
316314
317315public:
318316 // Initializes "this" to a state in which there are "n" tasks to be
319- // processed, none of the which are originally claimed. The number of
320- // threads doing the tasks is initialized 1.
317+ // processed, none of the which are originally claimed.
321318 SubTasksDone (uint n);
322319
323- // True iff the object is in a valid state.
324- bool valid ();
325-
326320 // Attempt to claim the task "t", returning true if successful,
327321 // false if it has already been claimed. The task "t" is required
328322 // to be within the range of "this".
@@ -331,21 +325,17 @@ class SubTasksDone: public CHeapObj<mtInternal> {
331325 // The calling thread asserts that it has attempted to claim all the tasks
332326 // that it will try to claim. Tasks that are meant to be skipped must be
333327 // explicitly passed as extra arguments. Every thread in the parallel task
334- // must execute this. (When the last thread does so, the task array is
335- // cleared.)
336- //
337- // n_threads - Number of threads executing the sub-tasks.
338- void all_tasks_completed (uint n_threads) {
339- all_tasks_completed_impl (n_threads, nullptr , 0 );
340- }
341-
342- // Augmented by variadic args, each for a skipped task.
328+ // must execute this.
343329 template <typename T0, typename ... Ts,
344330 ENABLE_IF (Conjunction<std::is_same<T0, Ts>...>::value)>
345- void all_tasks_completed (uint n_threads, T0 first_skipped, Ts... more_skipped) {
331+ void all_tasks_claimed ( T0 first_skipped, Ts... more_skipped) {
346332 static_assert (std::is_convertible<T0, uint>::value, " not convertible" );
347333 uint skipped[] = { static_cast <uint>(first_skipped), static_cast <uint>(more_skipped)... };
348- all_tasks_completed_impl (n_threads, skipped, ARRAY_SIZE (skipped));
334+ all_tasks_claimed_impl (skipped, ARRAY_SIZE (skipped));
335+ }
336+ // if there are no skipped tasks.
337+ void all_tasks_claimed () {
338+ all_tasks_claimed_impl (nullptr , 0 );
349339 }
350340
351341 // Destructor.
0 commit comments