xtd 1.0.0
Loading...
Searching...
No Matches
barrier.hpp
Go to the documentation of this file.
1
4#pragma once
6#include "../action.hpp"
7#include "../object.hpp"
8#include "../time_span.hpp"
9
11namespace xtd {
13 namespace threading {
30 class core_export_ barrier : public object {
31 struct data;
32 public:
34
37 using post_phase_action = xtd::action<barrier&>;
39
41
54
56 template<typename post_phase_action_t>
58 barrier();
59 barrier(barrier&&) = default;
60 barrier(const barrier&) = default;
61 auto operator =(const barrier& other) -> barrier&;
62 ~barrier();
64
66
71 [[nodiscard]] auto current_phase_number() const -> xtd::usize;
72
76 [[nodiscard]] auto participant_count() const -> xtd::usize;
77
82 [[nodiscard]] auto participants_remaining() const -> xtd::usize;
84
86
94
102
104 auto close() -> void;
105
111
118
122 auto signal_and_wait() -> void;
129 auto signal_and_wait(xtd::int32 milliseconds_timeout) -> bool;
143 auto signal_and_wait(const time_span& timeout) -> bool;
152 auto signal_and_wait(xtd::int32 milliseconds_timeout, const cancellation_token& cancellation_token) -> bool;
163
164 private:
165 auto wait_wtih_cancellation_token() -> bool;
166 auto wait_wtih_cancellation_token(xtd::int32 milliseconds_timeout) -> bool;
167
168 xtd::sptr<data> data_;
169 };
170 }
171}
Contains xtd::action delegate.
Contains xtd::threading::cancellation_token class.
object()=default
Create a new instance of the ultimate base class object.
Enables multiple tasks to cooperatively work on an algorithm in parallel through multiple phases.
Definition barrier.hpp:30
auto remove_participant() -> xtd::usize
Notifies the Barrier that there will be one less participant.
xtd::action< barrier & > post_phase_action
Represents the xtd::threading::barrier::post_phase_action delegate.
Definition barrier.hpp:37
auto signal_and_wait() -> void
Signals that a participant has reached the barrier and waits for all other participants to reach the ...
auto add_participant() -> xtd::usize
Notifies the xtd::threading::barrier that there will be an additional participant.
auto participant_count() const -> xtd::usize
Gets the total number of participants in the barrier.
auto current_phase_number() const -> xtd::usize
Gets the number of the barrier's current phase.
barrier(xtd::usize participant_count)
Initializes a new instance of the xtd::threading::barrier class.
auto add_participants(xtd::usize participant_count) -> xtd::usize
Notifies the xtd::threading::barrier that there will be additional participants.
auto remove_participants(xtd::usize participant_count) -> xtd::usize
Notifies the Barrier that there will be fewer participants.
barrier(xtd::usize participant_count, barrier::post_phase_action post_phase_action)
Initializes a new instance of the xtd::threading::barrier class.
auto participants_remaining() const -> xtd::usize
Gets the number of participants in the barrier that haven't yet signaled in the current phase.
auto close() -> void
Close the current 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
Represents a time interval.
Definition time_span.hpp:29
#define core_export_
Define shared library export.
Definition core_export.hpp:13
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:25
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
The xtd::threading namespace provides classes and interfaces that enable multithreaded programming....
Definition abandoned_mutex_exception.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
constexpr auto data() const noexcept -> const_pointer
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:197
Contains xtd::object class.
Contains xtd::time_span class.