Shows how to use xtd::threading::barrier class.
#include <xtd/xtd>
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());
barrier.signal_and_wait(1000);
console::write_line("Thread {} compelted the phase", thread::current_thread().managed_thread_id());
}
static constexpr int task_count = 3;
inline static threading::barrier barrier {task_count};
};
}
startup_(barrier_example::program::main);
#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:168