Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      Standard library header <semaphore> (C++20)

      From cppreference.com
      <cpp‎ |header
       
       
      Standard library headers
       

      This header is part of thethread support library.

      Classes

      semaphore that models a non-negative resource count
      (class template)[edit]
      semaphore that has only two states
      (typedef)[edit]

      [edit]Synopsis

      namespace std{template<ptrdiff_t LeastMaxValue=/* implementation-defined */>class counting_semaphore; using binary_semaphore= counting_semaphore<1>;}

      [edit]Class templatestd::counting_semaphore

      namespace std{template<ptrdiff_t LeastMaxValue=/* implementation-defined */>class counting_semaphore{public:staticconstexpr ptrdiff_t max()noexcept; constexprexplicit 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};}
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/header/semaphore&oldid=163980"

      [8]ページ先頭

      ©2009-2025 Movatter.jp