@@ -353,7 +353,7 @@ void WorkGangBarrierSync::abort() {
353353
354354SubTasksDone::SubTasksDone (uint n) :
355355 _tasks(NULL ), _n_tasks(n), _threads_completed(0 ) {
356- _tasks = NEW_C_HEAP_ARRAY (uint , n, mtInternal);
356+ _tasks = NEW_C_HEAP_ARRAY (bool , n, mtInternal);
357357 clear ();
358358}
359359
@@ -363,7 +363,7 @@ bool SubTasksDone::valid() {
363363
364364void SubTasksDone::clear () {
365365 for (uint i = 0 ; i < _n_tasks; i++) {
366- _tasks[i] = 0 ;
366+ _tasks[i] = false ;
367367 }
368368 _threads_completed = 0 ;
369369}
@@ -374,7 +374,7 @@ void SubTasksDone::all_tasks_completed_impl(uint n_threads,
374374#ifdef ASSERT
375375 // all non-skipped tasks are claimed
376376 for (uint i = 0 ; i < _n_tasks; ++i) {
377- if (_tasks[i] == 0 ) {
377+ if (! _tasks[i]) {
378378 auto is_skipped = false ;
379379 for (size_t j = 0 ; j < skipped_size; ++j) {
380380 if (i == skipped[j]) {
@@ -389,7 +389,7 @@ void SubTasksDone::all_tasks_completed_impl(uint n_threads,
389389 for (size_t i = 0 ; i < skipped_size; ++i) {
390390 auto task_index = skipped[i];
391391 assert (task_index < _n_tasks, " Array in range." );
392- assert (_tasks[task_index] == 0 , " %d is both claimed and skipped." , task_index);
392+ assert (! _tasks[task_index], " %d is both claimed and skipped." , task_index);
393393 }
394394#endif
395395 uint observed = _threads_completed;
@@ -407,17 +407,11 @@ void SubTasksDone::all_tasks_completed_impl(uint n_threads,
407407
408408bool SubTasksDone::try_claim_task (uint t) {
409409 assert (t < _n_tasks, " bad task id." );
410- uint old = _tasks[t];
411- if (old == 0 ) {
412- old = Atomic::cmpxchg (&_tasks[t], 0u , 1u );
413- }
414- bool res = old == 0 ;
415- return res;
410+ return !_tasks[t] && !Atomic::cmpxchg (&_tasks[t], false , true );
416411}
417412
418-
419413SubTasksDone::~SubTasksDone () {
420- FREE_C_HEAP_ARRAY (uint , _tasks);
414+ FREE_C_HEAP_ARRAY (bool , _tasks);
421415}
422416
423417// *** SequentialSubTasksDone
0 commit comments