dispenso 1.4.1
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
15#pragma once
16
17#include <dispenso/detail/completion_event_impl.h>
18#include <dispenso/task_set.h>
19
20namespace dispenso {
21
29 public:
37 template <typename F>
38 void schedule(F&& f) const {
39 f();
40 }
41
47 template <typename F>
48 void schedule(F&& f, ForceQueuingTag) const {
49 f();
50 }
51};
52
53constexpr ImmediateInvoker kImmediateInvoker;
54
61 public:
69 template <typename F>
70 void schedule(F&& f) const {
71 schedule(std::forward<F>(f), ForceQueuingTag());
72 }
80 template <typename F>
81 void schedule(F&& f, ForceQueuingTag) const {
82 std::thread thread([f = std::move(f)]() { f(); });
83 thread.detach();
84 }
85
86 private:
87};
88
89constexpr NewThreadInvoker kNewThreadInvoker;
90
91} // namespace dispenso
void schedule(F &&f) const
Definition schedulable.h:38
void schedule(F &&f, ForceQueuingTag) const
Definition schedulable.h:48
void schedule(F &&f, ForceQueuingTag) const
Definition schedulable.h:81
void schedule(F &&f) const
Definition schedulable.h:70