xtd 0.2.0
Loading...
Searching...
No Matches
countdown_event.h
Go to the documentation of this file.
1
4#pragma once
6#include "wait_handle.h"
7#include "../object.h"
8#include "../time_span.h"
9
11namespace xtd {
13 namespace threading {
31 struct data;
32 public:
34
40 explicit countdown_event(int32 initial_count);
42
46 countdown_event(const countdown_event&) = default;
47 countdown_event& operator =(const countdown_event& other);
50
52
58
63
68 bool is_set() const;
69
79
81
86 void add_count();
92 void add_count(int32 count);
93
95 void close();
96
100 void reset();
106 void reset(int32 count);
107
112 bool signal();
119 bool signal(int32 signal_count);
120
123 bool try_add_count() noexcept;
127 bool try_add_count(int32 count) noexcept;
128
132 void wait();
138 bool wait(int32 milliseconds_timeout);
150 bool wait(const time_span& timeout);
158 bool wait(int32 milliseconds_timeout, const cancellation_token& cancellation_token);
168
169 private:
170 xtd::sptr<data> data_;
171 bool wait_wtih_cancellation_token();
172 bool wait_wtih_cancellation_token(int32 milliseconds_timeout);
173 };
174 }
175}
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:42
Propagates notification that operations should be canceled.
Definition cancellation_token.h:39
Represents a synchronization primitive that is signaled when its count reaches zero.
Definition countdown_event.h:30
int32 current_count() const
Gets the number of remaining signals required to set the event.
bool try_add_count() noexcept
Attempts to increment xtd::threading::countdown_event::current_count by one.
countdown_event(int32 initial_count)
Initializes a new instance of xtd::threading::countdown_event class with the specified count.
const xtd::threading::wait_handle & wait_handle() const
Gets a xtd::threading::wait_handle that is used to wait for the event to be set.
void add_count()
Increments the xtd::threading::countdown_event's current count by one.
void reset(int32 count)
Resets the xtd::threading::countdown_event::initial_count property to a specified value.
bool signal()
Registers a signal with the xtd::threading::countdown_event, decrementing the value of xtd::threading...
bool is_set() const
ndicates whether the xtd::threading::countdown_event object's current count has reached zero.
void add_count(int32 count)
Increments the xtd::threading::countdown_event's current count by one.
xtd::threading::wait_handle & wait_handle()
Gets a xtd::threading::wait_handle that is used to wait for the event to be set.
void reset()
Resets the xtd::threading::countdown_event to the value of xtd::threading::countdown_event::initial_c...
void close()
Close the current instance of the xtd::threading::countdown_event class.
bool signal(int32 signal_count)
Registers multiple signals with the xtd::threading::countdown_event, decrementing the value of xtd::t...
int32 initial_count() const
Gets the numbers of signals initially required to set the event.
Contains a constant used to specify an infinite amount of time. This class cannot be inherited.
Definition timeout.h:33
Encapsulates operating system specific objects that wait for exclusive access to shared resources.
Definition wait_handle.h:52
#define core_export_
Define shared library export.
Definition core_export.h:13
int32_t int32
Represents a 32-bit signed integer.
Definition int32.h:23
std::shared_ptr< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.h:25
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:29
Contains xtd::threading::wait_handle exception.