// Author: K. Noel Belcourt #ifndef rendezvous_hpp #define rendezvous_hpp #include struct rendezvous { tbb::atomic increment; tbb::atomic task_counter; unsigned int n_tasks; rendezvous(unsigned int n) : n_tasks(n) { increment = true; task_counter = 0; } void wait() { if (increment) { if (n_tasks == ++task_counter) { increment = false; } else { while (increment) ; } } else { // decrement if (0 == --task_counter) { increment = true; } else { while (!increment) ; } } } }; #endif