dispenso
A library for task parallelism
 
Loading...
Searching...
No Matches
schedulable.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/detail/completion_event_impl.h>
17#include <dispenso/task_set.h>
18
19namespace dispenso {
20
28 public:
36 template <typename F>
37 void schedule(F&& f) const {
38 f();
39 }
40
46 template <typename F>
47 void schedule(F&& f, ForceQueuingTag) const {
48 f();
49 }
50};
51
52constexpr ImmediateInvoker kImmediateInvoker;
53
60 public:
68 template <typename F>
69 void schedule(F&& f) const {
70 schedule(std::forward<F>(f), ForceQueuingTag());
71 }
79 template <typename F>
80 void schedule(F&& f, ForceQueuingTag) const {
81 std::thread thread([f = std::move(f)]() { f(); });
82 thread.detach();
83 }
84
85 private:
86};
87
88constexpr NewThreadInvoker kNewThreadInvoker;
89
90} // namespace dispenso
void schedule(F &&f) const
Definition schedulable.h:37
void schedule(F &&f, ForceQueuingTag) const
Definition schedulable.h:47
void schedule(F &&f, ForceQueuingTag) const
Definition schedulable.h:80
void schedule(F &&f) const
Definition schedulable.h:69
detail::OpResult< T > OpResult
Definition pipeline.h:29