dispenso 1.4.1
A library for task parallelism
Loading...
Searching...
No Matches
completion_event.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
15#pragma once
16
17#include <dispenso/platform.h>
18
19#include <dispenso/detail/completion_event_impl.h>
20
21namespace dispenso {
22
31 public:
36 void notify() {
37 impl_.notify(1);
38 }
39
43 void wait() const {
44 impl_.wait(1);
45 }
46
50 bool completed() const {
51 return impl_.intrusiveStatus().load(std::memory_order_acquire);
52 }
53
60 template <class Rep, class Period>
61 bool waitFor(const std::chrono::duration<Rep, Period>& relTime) const {
62 return impl_.waitFor(1, relTime);
63 }
64
71 template <class Clock, class Duration>
72 bool waitUntil(const std::chrono::time_point<Clock, Duration>& absTime) const {
73 return impl_.waitUntil(1, absTime);
74 }
75
80 void reset() {
81 impl_.intrusiveStatus().store(0, std::memory_order_seq_cst);
82 }
83
84 private:
85 detail::CompletionEventImpl impl_{0};
86};
87
88} // namespace dispenso
bool waitFor(const std::chrono::duration< Rep, Period > &relTime) const
bool waitUntil(const std::chrono::time_point< Clock, Duration > &absTime) const