xtd 0.2.0
Loading...
Searching...
No Matches
barrier.hpp
Go to the documentation of this file.
1
4#pragma once
7#include "../action.hpp"
8#include "../object.hpp"
9#include "../time_span.hpp"
10
12namespace xtd {
14 namespace threading {
31 class core_export_ barrier : public object {
32 struct data;
33 public:
35
40
42
47 explicit barrier(int32 participant_count);
55
57 template <typename post_phase_action_t>
58 barrier(int32 participant_count, post_phase_action_t post_phase_action) : barrier(participant_count, barrier::post_phase_action {post_phase_action}) {}
59 barrier();
60 barrier(barrier&&) = default;
61 barrier(const barrier&) = default;
62 barrier& operator =(const barrier& other);
63 ~barrier();
65
67
73
78
85
87
95
102 int32 add_participants(int32 participant_count);
103
105 void close();
106
112
118 int32 remove_participants(int32 participant_count);
119
130 bool signal_and_wait(int32 milliseconds_timeout);
153 bool signal_and_wait(int32 milliseconds_timeout, const cancellation_token& cancellation_token);
164
165 private:
166 bool wait_wtih_cancellation_token();
167 bool wait_wtih_cancellation_token(int32 milliseconds_timeout);
168
169 xtd::sptr<data> data_;
170 };
171 }
172}
Contains xtd::threading::barrier_post_phase_exception exception.
Contains xtd::threading::cancellation_token class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:42
Enables multiple tasks to cooperatively work on an algorithm in parallel through multiple phases.
Definition barrier.hpp:31
int32 remove_participant()
Notifies the Barrier that there will be one less participant.
barrier(int32 participant_count)
Initializes a new instance of the xtd::threading::barrier class.
action< barrier & > post_phase_action
Represents the xtd::threading::barrier::post_phase_action delegate.
Definition barrier.hpp:38
int32 add_participants(int32 participant_count)
Notifies the xtd::threading::barrier that there will be additional participants.
bool signal_and_wait(const time_span &timeout)
Signals that a participant has reached the barrier and waits for all other participants to reach the ...
bool signal_and_wait(int32 milliseconds_timeout)
Signals that a participant has reached the barrier and waits for all other participants to reach the ...
bool signal_and_wait(const time_span &timeout, const cancellation_token &cancellation_token)
Signals that a participant has reached the barrier and waits for all other participants to reach the ...
bool signal_and_wait(const cancellation_token &cancellation_token)
Signals that a participant has reached the barrier and waits for all other participants to reach the ...
int32 participant_count() const
Gets the total number of participants in the barrier.
int32 add_participant()
Notifies the xtd::threading::barrier that there will be an additional participant.
bool signal_and_wait(int32 milliseconds_timeout, const cancellation_token &cancellation_token)
Signals that a participant has reached the barrier and waits for all other participants to reach the ...
int32 remove_participants(int32 participant_count)
Notifies the Barrier that there will be fewer 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 ...
int32 participants_remaining() const
Gets the number of participants in the barrier that haven't yet signaled in the current phase.
int32 current_phase_number() const
Gets the number of the barrier's current phase.
barrier(int32 participant_count, barrier::post_phase_action post_phase_action)
Initializes a new instance of the xtd::threading::barrier class.
Propagates notification that operations should be canceled.
Definition cancellation_token.hpp:39
Contains a constant used to specify an infinite amount of time. This class cannot be inherited.
Definition timeout.hpp:33
#define core_export_
Define shared library export.
Definition core_export.hpp:13
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
std::shared_ptr< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
delegate< void(arguments_t...)> action
Represents a xtd::delegate that has variable parameters and does not return a value.
Definition action.hpp:20
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Represents a time interval.
Definition time_span.hpp:29