FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
taskflow/taskflow/algorithm/launch.hpp at master · PentaBug/taskflow · GitHub
PentaBug
taskflow
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
taskflow
/
taskflow
/
algorithm
/
launch.hpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
76 lines (64 loc) · 1.55 KB
Breadcrumbs
taskflow
/
taskflow
/
algorithm
/
launch.hpp
Copy path
File metadata and controls
76 lines (64 loc) · 1.55 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#
pragma
once
#
include
<
functional
>
#
include
"
../core/async.hpp
"
namespace
tf
{
//
Function: launch_loop
template
<
typename
P,
typename
Loop>
TF_FORCE_INLINE
void
launch_loop
(P part, Loop loop) {
constexpr
bool
is_default_wrapper_v = std::is_same_v<
typename
std::
decay_t
<P>::closure_wrapper_type, DefaultClosureWrapper
>;
if
constexpr
(is_default_wrapper_v) {
loop
();
}
else
{
std::invoke
(part.
closure_wrapper
(), loop);
}
}
//
Function: launch_loop
template
<
typename
P,
typename
Loop>
TF_FORCE_INLINE
void
launch_loop
(
size_t
N,
size_t
W,
Runtime& rt,
std::atomic<
size_t
>& next,
P part,
Loop loop
) {
//
static_assert(std::is_lvalue_reference_v<Loop>, "");
using
namespace
std
::string_literals
;
for
(
size_t
w=
0
; w<W; w++) {
auto
r = N - next.
load
(std::memory_order_relaxed);
//
no more loop work to do - finished by previous async tasks
if
(!r) {
break
;
}
//
tail optimization
if
(r <= part.
chunk_size
() || w == W-
1
) {
launch_loop
(part, loop);
break
;
}
else
{
rt.
silent_async_unchecked
([=](){
launch_loop
(part, loop); });
}
}
rt.
corun_all
();
}
//
Function: launch_loop
template
<
typename
P,
typename
Loop>
TF_FORCE_INLINE
void
launch_loop
(
size_t
W,
size_t
w,
Runtime& rt,
P part,
Loop loop
) {
using
namespace
std
::string_literals
;
if
(w == W-
1
) {
launch_loop
(part, loop);
}
else
{
rt.
silent_async_unchecked
([=](){
launch_loop
(part, loop); });
}
}
}
//
end of namespace tf -----------------------------------------------------
Back
|
FazBrowse Home
|
New Git URL