xtd 0.2.0
countdown_event.h
Go to the documentation of this file.
1 #pragma once
5 #include "cancellation_token.h"
6 #include "wait_handle.h"
7 #include "../object.h"
8 #include "../time_span.h"
9 
11 namespace xtd {
13  namespace threading {
28  class core_export_ countdown_event : public object {
29  struct data;
30  public:
32 
38  explicit countdown_event(int32 initial_count);
40 
43  countdown_event(countdown_event&&) = default;
44  countdown_event(const countdown_event&) = default;
45  countdown_event& operator =(const countdown_event& other);
46  ~countdown_event();
48 
50 
55  int32 current_count() const;
56 
60  int32 initial_count() const;
61 
66  bool is_set() const;
67 
75  xtd::threading::wait_handle& wait_handle();
77 
79 
84  void add_count();
90  void add_count(int32 count);
91 
93  void close();
94 
98  void reset();
104  void reset(int32 count);
105 
110  bool signal();
117  bool signal(int32 signal_count);
118 
121  bool try_add_count() noexcept;
125  bool try_add_count(int32 count) noexcept;
126 
130  void wait();
136  bool wait(int32 milliseconds_timeout);
142  void wait(const cancellation_token& cancellation_token);
148  bool wait(const time_span& timeout);
156  bool wait(int32 milliseconds_timeout, const cancellation_token& cancellation_token);
164  bool wait(const time_span& timeout, const cancellation_token& cancellation_token);
166 
167  private:
168  std::shared_ptr<data> data_;
169  bool wait_wtih_cancellation_token();
170  bool wait_wtih_cancellation_token(int32 milliseconds_timeout);
171  };
172  }
173 }
signal
Specifies signals that can interrupt the current process.
Definition: signal.h:18
Contains xtd::threading::wait_handle exception.
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Contains xtd::threading::cancellation_token class.
Represents a synchronization primitive that is signaled when its count reaches zero.
Definition: countdown_event.h:28
The operating system is other.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:32
Represents a time interval.
Definition: time_span.h:26
int_least32_t int32
Represents a 32-bit signed integer.
Definition: types.h:129
Contains a constant used to specify an infinite amount of time. This class cannot be inherited...
Definition: timeout.h:31
Propagates notification that operations should be canceled.
Definition: cancellation_token.h:37
Encapsulates operating system specific objects that wait for exclusive access to shared resources...
Definition: wait_handle.h:48