xtd 0.2.0
Loading...
Searching...
No Matches
countdown_event.hpp
Go to the documentation of this file.
1
4#pragma once
6#include "wait_handle.hpp"
7#include "../object.hpp"
8#include "../time_span.hpp"
9
11namespace xtd {
13 namespace threading {
31 struct data;
32 public:
34
42
46 countdown_event(const countdown_event&) = default;
47 auto operator =(countdown_event&& other) -> countdown_event& = default;
48 auto operator =(const countdown_event& other) -> countdown_event&;
51
53
58 [[nodiscard]] auto current_count() const -> xtd::size;
59
63 [[nodiscard]] auto initial_count() const -> xtd::size;
64
69 [[nodiscard]] auto is_set() const -> bool;
70
74 [[nodiscard]] auto wait_handle() const -> const xtd::threading::wait_handle&;
78 [[nodiscard]] auto wait_handle() -> xtd::threading::wait_handle&;
80
82
87 auto add_count() -> void;
93 auto add_count(xtd::size count) -> void;
94
96 auto close() -> void;
97
101 auto reset() -> void;
107 void reset(xtd::size count);
108
113 auto signal() -> bool;
120 auto signal(xtd::size signal_count) -> bool;
121
124 auto try_add_count() noexcept -> bool;
128 auto try_add_count(xtd::size count) noexcept -> bool;
129
133 auto wait() -> void;
139 auto wait(xtd::int32 milliseconds_timeout) -> bool;
151 auto wait(const xtd::time_span& timeout) -> bool;
159 auto wait(xtd::int32 milliseconds_timeout, const cancellation_token& cancellation_token) -> bool;
169
170 private:
171 xtd::sptr<data> data_;
172 auto wait_wtih_cancellation_token() -> bool;
173 auto wait_wtih_cancellation_token(xtd::int32 milliseconds_timeout) -> bool;
174 };
175 }
176}
Contains xtd::threading::cancellation_token class.
object()=default
Create a new instance of the ultimate base class object.
Propagates notification that operations should be canceled.
Definition cancellation_token.hpp:39
auto add_count() -> void
Increments the xtd::threading::countdown_event's current count by one.
auto signal() -> bool
Registers a signal with the xtd::threading::countdown_event, decrementing the value of xtd::threading...
auto reset() -> void
Resets the xtd::threading::countdown_event to the value of xtd::threading::countdown_event::initial_c...
auto initial_count() const -> xtd::size
Gets the numbers of signals initially required to set the event.
auto close() -> void
Close the current instance of the xtd::threading::countdown_event class.
auto current_count() const -> xtd::size
Gets the number of remaining signals required to set the event.
auto try_add_count() noexcept -> bool
Attempts to increment xtd::threading::countdown_event::current_count by one.
auto wait() -> void
Blocks the current thread until the xtd::threading::countdown_event is set.
auto wait_handle() const -> const xtd::threading::wait_handle &
Gets a xtd::threading::wait_handle that is used to wait for the event to be set.
countdown_event(xtd::size initial_count)
Initializes a new instance of xtd::threading::countdown_event class with the specified count.
auto is_set() const -> bool
ndicates whether the xtd::threading::countdown_event object's current count has reached zero.
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
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
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:23
@ other
The operating system is other.
Definition platform_id.hpp:60
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 const_pointer data() const noexcept
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:201
Contains xtd::object class.
Contains xtd::time_span class.
Contains xtd::threading::wait_handle class.