Namespaces
Variants

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

From cppreference.net
Standard library headers

此头文件是 线程支持 库的组成部分。

(C++20)
可复用线程屏障
(类模板)

概要

namespace std {
  template<class CompletionFunction = /* 参见描述 */>
    class barrier;
}

类模板 std::barrier

namespace std {
  template<class CompletionFunction = /* 见描述 */>
  class barrier {
  public:
    using arrival_token =  /* 见描述 */;
    static constexpr ptrdiff_t max() noexcept;
    constexpr explicit barrier(ptrdiff_t expected,
                               CompletionFunction f = CompletionFunction());
    ~barrier();
    barrier(const barrier&) = delete;
    barrier& operator=(const barrier&) = delete;
    arrival_token arrive(ptrdiff_t update = 1);
    void wait(arrival_token&& arrival) const;
    void arrive_and_wait();
    void arrive_and_drop();
  private:
    CompletionFunction completion;      // 仅用于说明
  };
}