xtd 0.2.0
Loading...
Searching...
No Matches
barrier.h
Go to the documentation of this file.
1
4#pragma once
7#include "../action.h"
8#include "../object.h"
9#include "../time_span.h"
10
12namespace xtd {
14 namespace threading {
29 class core_export_ barrier : public object {
30 struct data;
31 public:
33
38
40
45 explicit barrier(int32 participant_count);
53
55 template <typename post_phase_action_t>
56 barrier(int32 participant_count, post_phase_action_t post_phase_action) : barrier(participant_count, barrier::post_phase_action {post_phase_action}) {}
57 barrier();
58 barrier(barrier&&) = default;
59 barrier(const barrier&) = default;
60 barrier& operator =(const barrier& other);
61 ~barrier();
63
65
71
76
83
85
93
100 int32 add_participants(int32 participant_count);
101
103 void close();
104
110
116 int32 remove_participants(int32 participant_count);
117
128 bool signal_and_wait(int32 milliseconds_timeout);
151 bool signal_and_wait(int32 milliseconds_timeout, const cancellation_token& cancellation_token);
162
163 private:
164 bool wait_wtih_cancellation_token();
165 bool wait_wtih_cancellation_token(int32 milliseconds_timeout);
166
167 std::shared_ptr<data> data_;
168 };
169 }
170}
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.h:32
Enables multiple tasks to cooperatively work on an algorithm in parallel through multiple phases.
Definition barrier.h:29
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.h:36
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.h:37
Contains a constant used to specify an infinite amount of time. This class cannot be inherited.
Definition timeout.h:31
#define core_export_
Define shared library export.
Definition core_export.h:13
int_least32_t int32
Represents a 32-bit signed integer.
Definition types.h:131
delegate< void(arguments_t...)> action
Represents a xtd::delegate that has variable parameters and does not return a value.
Definition action.h:18
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Represents a time interval.
Definition time_span.h:26