53 friend class registered_wait_handle;
160 template<class collection_t>
171 template<
class collection_t>
172 static bool wait_all(
const collection_t& wait_handles,
int32 milliseconds_timeout) {
173 auto wait_handle_pointers = std::vector<wait_handle*> {};
174 for (
auto& item : wait_handles)
172 static bool wait_all(
const collection_t& wait_handles,
int32 milliseconds_timeout) {
…}
187 template<
class collection_t>
197 template<
class collection_t>
208 template<
class collection_t>
209 static size_t wait_any(
const collection_t& wait_handles,
int32 milliseconds_timeout) {
210 auto wait_handle_pointers = std::vector<wait_handle*> {};
211 for (
auto& item : wait_handles)
209 static size_t wait_any(
const collection_t& wait_handles,
int32 milliseconds_timeout) {
…}
224 template<
class collection_t>
229 template<
class ...items_t>
230 static bool wait_all(items_t... items) {
return wait_all(
timeout::infinite, items...);}
231 template<
class ...items_t>
233 template<
class ...items_t>
234 static bool wait_all(int32 milliseconds_timeout, items_t... items) {
235 auto wait_handle_pointers = std::vector<wait_handle*> {};
236 fill_wait_handle_pointers(wait_handle_pointers, items...);
237 return wait_all(xtd::array<wait_handle*> {wait_handle_pointers}, milliseconds_timeout);
239 template<
class item_t>
240 static bool wait_all(
const std::initializer_list<item_t>& wait_handles) {
return wait_all(wait_handles, timeout::infinite);}
241 template<
class item_t>
242 static bool wait_all(
const std::initializer_list<item_t>& wait_handles, int32 milliseconds_timeout) {
243 auto wait_handle_pointers = std::vector<wait_handle*> {};
244 for (
auto& item : wait_handles)
245 wait_handle_pointers.push_back(
const_cast<wait_handle*
>(as<wait_handle>(&item)));
246 return wait_all(xtd::array<wait_handle*> {wait_handle_pointers}, milliseconds_timeout);
248 template<
class item_t>
249 static bool wait_all(
const std::initializer_list<item_t>& wait_handles,
const time_span& timeout) {
return wait_all(wait_handles, as<int32>(timeout.total_milliseconds_duration().count()));}
251 static bool wait_all(
const std::initializer_list<
xtd::sptr<wait_handle>>& wait_handles, int32 milliseconds_timeout);
252 static bool wait_all(
const std::initializer_list<
xtd::sptr<wait_handle>>& wait_handles,
const time_span& timeout);
254 static bool wait_all(
const std::initializer_list<
xtd::uptr<wait_handle>>& wait_handles, int32 milliseconds_timeout);
255 static bool wait_all(
const std::initializer_list<
xtd::uptr<wait_handle>>& wait_handles,
const time_span& timeout);
262 static bool wait_all(
const xtd::array<wait_handle*>& wait_handles, int32 milliseconds_timeout);
264 template<
class ...items_t>
265 static size_t wait_any(items_t... items) {
return wait_any(timeout::infinite, items...);}
266 template<
class ...items_t>
267 static size_t wait_any(
const time_span& timeout, items_t... items) {
return wait_any(as<int32>(timeout.total_milliseconds()), items...);}
268 template<
class ...items_t>
269 static size_t wait_any(int32 milliseconds_timeout, items_t... items) {
270 auto wait_handle_pointers = std::vector<wait_handle*> {};
271 fill_wait_handle_pointers(wait_handle_pointers, items...);
272 return wait_any(xtd::array<wait_handle*> {wait_handle_pointers}, milliseconds_timeout);
274 template<
class item_t>
275 static size_t wait_any(
const std::initializer_list<item_t>& wait_handles) {
return wait_any(wait_handles, timeout::infinite);}
276 template<
class item_t>
277 static size_t wait_any(
const std::initializer_list<item_t>& wait_handles, int32 milliseconds_timeout) {
278 auto wait_handle_pointers = std::vector<wait_handle*> {};
279 for (
auto& item : wait_handles)
280 wait_handle_pointers.push_back(
const_cast<wait_handle*
>(as<wait_handle>(&item)));
281 return wait_any(xtd::array<wait_handle*> {wait_handle_pointers}, milliseconds_timeout);
283 template<
class item_t>
284 static size_t wait_any(
const std::initializer_list<item_t>& wait_handles,
const time_span& timeout) {
return wait_any(wait_handles, as<int32>(timeout.total_milliseconds_duration().count()));}
286 static size_t wait_any(
const std::initializer_list<
xtd::sptr<wait_handle>>& wait_handles, int32 milliseconds_timeout);
287 static size_t wait_any(
const std::initializer_list<
xtd::sptr<wait_handle>>& wait_handles,
const time_span& timeout);
289 static size_t wait_any(
const std::initializer_list<
xtd::uptr<wait_handle>>& wait_handles, int32 milliseconds_timeout);
290 static size_t wait_any(
const std::initializer_list<
xtd::uptr<wait_handle>>& wait_handles,
const time_span& timeout);
292 static size_t wait_any(
const xtd::array<
xtd::sptr<wait_handle>>& wait_handles, int32 milliseconds_timeout);
295 static size_t wait_any(
const xtd::array<
xtd::uptr<wait_handle>>& wait_handles, int32 milliseconds_timeout);
297 static size_t wait_any(
const xtd::array<wait_handle*>& wait_handles, int32 milliseconds_timeout);
319 template<
class item_t,
class ...items_t>
320 static void fill_wait_handle_pointers(std::vector<wait_handle*>& wait_handle_pointers, item_t&
first, items_t& ... rest) {
322 fill_wait_handle_pointers(wait_handle_pointers, rest...);
324 template<
class item_t>
325 static void fill_wait_handle_pointers(std::vector<wait_handle*>& wait_handle_pointers, item_t& item) {
Contains xtd::abstract_object class.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:61
static constexpr size_t max_value
Definition box_integer.hpp:67
A synchronization primitive that can also be used for interprocess synchronization.
Definition registered_wait_handle.hpp:29
Creates and controls a thread, sets its priority, and gets its status.
Definition thread.hpp:45
Contains a constant used to specify an infinite amount of time. This class cannot be inherited.
Definition timeout.hpp:33
static constexpr int32 infinite
A constant used to specify an infinite waiting period. This field is constant.
Definition timeout.hpp:41
Encapsulates operating system specific objects that wait for exclusive access to shared resources.
Definition wait_handle.hpp:52
static bool signal_and_wait(wait_handle &to_signal, wait_handle &to_wait)
Signals one xtd::threading::wait_handle and waits on another.
virtual void close()
Releases all resources held by the current xtd::threading::wait_handle.
static const intptr invalid_handle
Represents an invalid native operating system handle. This field is read-only.
Definition wait_handle.hpp:63
static bool wait_all(const collection_t &wait_handles)
Waits for all the elements in the specified collection to receive a signal.
Definition wait_handle.hpp:161
static size_t wait_any(const collection_t &wait_handles, int32 milliseconds_timeout)
Waits for any of the elements in the specified collection to receive a signal, using a 32-bit signed ...
Definition wait_handle.hpp:209
wait_handle()=default
Initializes a new instance of the xtd::threading::wait_handle class.
static constexpr size_t wait_timeout
Indicates that a xtd::threading::wait_handle::wait_any operation timed out before any of the wait han...
Definition wait_handle.hpp:67
static bool wait_all(const collection_t &wait_handles, int32 milliseconds_timeout)
Waits for all the elements in the specified collection to receive a signal, using an int32 value to m...
Definition wait_handle.hpp:172
virtual bool wait(int32 milliseconds_timeout)=0
wait ownership of the specified mutex object.
virtual bool wait_one()
Blocks the current thread until the current xtd::threading::wait_handle receives a signal.
virtual intptr handle() const noexcept=0
Gets the native operating system handle.
virtual bool signal()=0
Releases ownership of the specified wait_handle object.
static bool wait_all(const collection_t &wait_handles, const time_span &timeout)
Waits for all the elements in the specified collection to receive a signal, using a xtd::time_span va...
Definition wait_handle.hpp:188
static size_t wait_any(const collection_t &wait_handles)
Waits for any of the elements in the specified collection to receive a signal.
Definition wait_handle.hpp:198
static size_t wait_any(const collection_t &wait_handles, const time_span &timeout)
Waits for any of the elements in the specified collection to receive a signal, using a xtd::time_span...
Definition wait_handle.hpp:225
Represents a time interval.
Definition time_span.hpp:29
double total_milliseconds() const noexcept
Gets the value of the current xtd::time_span structure expressed in whole and fractional milliseconds...
#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
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
xtd::unique_ptr_object< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.hpp:25
intmax_t intptr
Represent a pointer or a handle.
Definition intptr.hpp:23
type_t as(any_object &o)
Casts a type into another type.
Definition __as_any_object.hpp:59
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
read_only_span< type_t, count > first() const
Obtains a subspan consisting of the first count elements of the sequence.
Definition read_only_span.hpp:282
Contains xtd::size_object alias.
Contains xtd::time_span class.
Contains xtd::threading::timeout class.
Contains xtd fundamental types.