Standardbibliotheks-Header <semaphore> (C++20)
Von cppreference.com
Dieser Header ist Teil der Thread-Unterstützungs-Bibliothek.
Klassen | |
| (C++20) |
Semaphor, das eine nicht-negative Ressource zählt (Klassenvorlage) |
| (C++20) |
Semaphor, das nur zwei Zustände hat (typedef) |
[edit] Synopsis
namespace std { template<ptrdiff_t LeastMaxValue = /* implementation-defined */> class counting_semaphore; using binary_semaphore = counting_semaphore<1>; }
[edit] Klassenvorlage std::counting_semaphore
namespace std { template<ptrdiff_t LeastMaxValue = /* implementation-defined */> class counting_semaphore { public: static constexpr ptrdiff_t max() noexcept; constexpr explicit counting_semaphore(ptrdiff_t desired); ~counting_semaphore(); counting_semaphore(const counting_semaphore&) = delete; counting_semaphore& operator=(const counting_semaphore&) = delete; void release(ptrdiff_t update = 1); void acquire(); bool try_acquire() noexcept; template<class Rep, class Period> bool try_acquire_for(const chrono::duration<Rep, Period>& rel_time); template<class Clock, class Duration> bool try_acquire_until(const chrono::time_point<Clock, Duration>& abs_time); private: ptrdiff_t counter; // exposition only }; }