#include <xtd/threading/barrier>
#include <xtd/threading/thread_pool>
#include <xtd/console>
#include <xtd/startup>
namespace barrier_example {
class program {
public:
static void main() {
for (auto index = 0; index < task_count; ++index)
thread_pool::queue_user_work_item(perform_phase);
}
private:
static void perform_phase() {
console::write_line("Thread {} is performing its work", thread::current_thread().managed_thread_id());
console::write_line("Thread {} compelted the phase", thread::current_thread().managed_thread_id());
}
static constexpr int task_count = 3;
};
}
startup_(barrier_example::program::main);
Enables multiple tasks to cooperatively work on an algorithm in parallel through multiple phases.
Definition barrier.hpp:31
void signal_and_wait()
Signals that a participant has reached the barrier and waits for all other participants to reach the ...
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:175
The xtd::threading namespace provides classes and interfaces that enable multithreaded programming....
Definition abandoned_mutex_exception.hpp:11
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10