dispenso
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
14#pragma once
15
16#include <dispenso/platform.h>
17
18#include <dispenso/detail/completion_event_impl.h>
19
20namespace dispenso {
21
30 public:
35 void notify() {
36 impl_.notify(1);
37 }
38
42 void wait() const {
43 impl_.wait(1);
44 }
45
49 bool completed() const {
50 return impl_.intrusiveStatus().load(std::memory_order_acquire);
51 }
52
59 template <class Rep, class Period>
60 bool waitFor(const std::chrono::duration<Rep, Period>& relTime) const {
61 return impl_.waitFor(1, relTime);
62 }
63
70 template <class Clock, class Duration>
71 bool waitUntil(const std::chrono::time_point<Clock, Duration>& absTime) const {
72 return impl_.waitUntil(1, absTime);
73 }
74
79 void reset() {
80 impl_.intrusiveStatus().store(0, std::memory_order_seq_cst);
81 }
82
83 private:
84 detail::CompletionEventImpl impl_{0};
85};
86
87} // namespace dispenso
bool waitFor(const std::chrono::duration< Rep, Period > &relTime) const
bool waitUntil(const std::chrono::time_point< Clock, Duration > &absTime) const
detail::OpResult< T > OpResult
Definition pipeline.h:29