#include <xtd/threading/barrier>
#include <xtd/threading/interlocked>
#include <xtd/threading/thread_pool>
#include <xtd/console>
#include <xtd/startup>
namespace barrier_example {
class program {
public:
static void main() {
auto count = 0;
console::write_line("Post-Phase action: count={0}, phase={1}", count, b.current_phase_number());
}}};
interlocked::increment(count);
interlocked::increment(count);
interlocked::increment(count);
try {
console::write_line(
"Caught barrier_post_phase_exception: {0}", bppe.
message());
}
interlocked::increment(count);
};
for (auto index = 0; index < 4; ++index)
thread_pool::queue_user_work_item(
action);
thread::join_all();
}
};
}
startup_(barrier_example::program::main);
virtual const xtd::string & message() const noexcept
Gets message associate to the exception.
The exception that is thrown when a method call is invalid for the object's current state.
Definition system_exception.h:18
The exception that is thrown when a Thread is in an invalid ThreadState for the method call.
Definition barrier_post_phase_exception.h:28
Enables multiple tasks to cooperatively work on an algorithm in parallel through multiple phases.
Definition barrier.h:31
int32 remove_participant()
Notifies the Barrier that there will be one less participant.
int32 add_participants(int32 participant_count)
Notifies the xtd::threading::barrier that there will be additional participants.
void close()
Close the current instance of the xtd::threading::barrier class.
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.h:175
delegate< void(arguments_t...)> action
Represents a xtd::delegate that has variable parameters and does not return a value.
Definition action.h:20
The xtd::threading namespace provides classes and interfaces that enable multithreaded programming....
Definition abandoned_mutex_exception.h:11
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10