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
20
namespace
dispenso {
21
28
class
ImmediateInvoker
{
29
public
:
37
template
<
typename
F>
38
DISPENSO_REQUIRES(OnceCallableFunc<F>)
39
void
schedule
(F&& f)
const
{
40
f();
41
}
42
48
template
<
typename
F>
49
DISPENSO_REQUIRES(OnceCallableFunc<F>)
50
void
schedule
(F&& f, ForceQueuingTag)
const
{
51
f();
52
}
53
};
54
55
constexpr
ImmediateInvoker kImmediateInvoker;
56
62
class
NewThreadInvoker
{
63
public
:
71
template
<
typename
F>
72
DISPENSO_REQUIRES(OnceCallableFunc<F>)
73
void
schedule
(F&& f)
const
{
74
schedule
(std::forward<F>(f), ForceQueuingTag());
75
}
83
template
<
typename
F>
84
DISPENSO_REQUIRES(OnceCallableFunc<F>)
85
void
schedule
(F&& f, ForceQueuingTag)
const
{
86
std::thread thread([f = std::move(f)]() { f(); });
87
thread.detach();
88
}
89
90
private
:
91
};
92
93
constexpr
NewThreadInvoker kNewThreadInvoker;
94
95
}
// namespace dispenso
dispenso::ImmediateInvoker
Definition
schedulable.h:28
dispenso::ImmediateInvoker::schedule
void schedule(F &&f) const
Definition
schedulable.h:39
dispenso::NewThreadInvoker
Definition
schedulable.h:62
dispenso::NewThreadInvoker::schedule
void schedule(F &&f) const
Definition
schedulable.h:73
task_set.h
dispenso
schedulable.h
Generated by
1.12.0