xtd: xtd.core/include/xtd/threading/semaphore.hpp Source File (original) (raw)

1

4#pragma once

10

12namespace xtd {

39 class semaphore_base;

40 class named_semaphore;

41 class unnamed_semaphore;

43 public:

45

70 explicit semaphore(const string& name, bool& created_new);

101 semaphore(int32 initial_count, const string& name, bool& created_new);

139 semaphore(int32 initial_count, int32 maximum_count, const string& name, bool& created_new);

141

143 template<class char_t>

147

149

154

156

159

160 int32 compare_to(const semaphore& value) const noexcept override;

161

165 bool equals(const object& obj) const noexcept override;

170

187

189

200

210

211 protected:

213

216

217 bool wait(int32 milliseconds_timeout) override;

219

220 private:

221 void create(int32 initial_count, int32 maximum_count, bool& created_new);

222 xtd::sptr<semaphore_base> semaphore_;

224 };

225 }

226}

Defines a generalized comparison method that a value type or class implements to create a type-specif...

Definition icomparable.hpp:21

Defines a generalized method that a value type or class implements to create a type-specific method f...

Definition iequatable.hpp:22

Limits the number of threads that can access a resource or pool of resources concurrently.

Definition semaphore.hpp:38

semaphore(const string &name, bool &created_new)

Initializes a new instance of the xtd::threading::semaphore class, specifying optionally specifying t...

semaphore(int32 initial_count, const string &name, bool &created_new)

Initializes a new instance of the xtd::threading::semaphore class, specifying the initial number of e...

semaphore(int32 initial_count, int32 maximum_count, const string &name, bool &created_new)

Initializes a new instance of the xtd::threading::semaphore class, specifying the initial number of e...

bool equals(const object &obj) const noexcept override

Determines whether the specified object is equal to the current object.

semaphore(int32 initial_count, int32 maximum_count, const string &name)

Initializes a new instance of the xtd::threading::semaphore class, specifying the initial number of e...

semaphore(int32 initial_count, int32 maximum_count)

Initializes a new instance of the xtd::threading::semaphore class, specifying the initial number of e...

semaphore(const string &name)

Initializes a new instance of the xtd::threading::semaphore class, specifying optionally specifying t...

semaphore()

Initializes a new instance of the xtd::threading::semaphore class.

semaphore(int32 initial_count, const string &name)

Initializes a new instance of the xtd::threading::semaphore class, specifying the initial number of e...

static bool try_open_existing(const string &name, semaphore &result) noexcept

Opens the specified named semaphore, if it already exists, and returns a value that indicates whether...

intptr handle() const noexcept override

Gets the native operating system handle.

void close() override

Releases all resources held by the current xtd::threading::wait_handle.

bool signal() override

Releases ownership of the specified wait_handle object.

semaphore(int32 initial_count)

Initializes a new instance of the xtd::threading::semaphore class, specifying the initial number of e...

static semaphore open_existing(const string &name)

Opens the specified named semaphore, if it already exists.

bool wait(int32 milliseconds_timeout) override

wait ownership of the specified mutex object.

int32 release()

Exits the semaphore and returns the previous count.

wait_handle()=default

Initializes a new instance of the xtd::threading::wait_handle class.

#define core_export_

Define shared library export.

Definition core_export.hpp:13

xtd::basic_string< char > string

Represents text as a sequence of UTF-8 code units.

Definition __string_definitions.hpp:43

xtd::shared_ptr_object< type_t > sptr

The xtd::sptr object is a shared pointer.

Definition sptr.hpp:25

intmax_t intptr

Represent a pointer or a handle.

Definition intptr.hpp:23

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

Contains xtd::icomparable interface.

Contains xtd::iequatable interface.

Contains xtd::int32_object alias.

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::threading::semaphore_full_exception exception.

Contains xtd::threading::wait_handle class.