FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-taskflow/taskflow/core/topology.hpp at cpp14 · gicho/cpp-taskflow · GitHub
gicho
cpp-taskflow
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpp-taskflow
/
taskflow
/
core
/
topology.hpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
74 lines (51 loc) · 1.46 KB
Breadcrumbs
cpp-taskflow
/
taskflow
/
core
/
topology.hpp
Copy path
File metadata and controls
74 lines (51 loc) · 1.46 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
#
pragma
once
//
#include "taskflow.hpp"
namespace
tf
{
//
----------------------------------------------------------------------------
//
class: Topology
class
Topology
{
friend
class
Taskflow
;
friend
class
Executor
;
public:
template
<
typename
P,
typename
C>
Topology
(Taskflow&, P&&, C&&);
private:
Taskflow& _taskflow;
std::promise<
void
> _promise;
PassiveVector<Node*> _sources;
std::atomic<
int
> _num_sinks {
0
};
int
_cached_num_sinks {
0
};
std::function<
bool
()> _pred;
std::function<
void
()> _call;
void
_bind
(Graph& g);
void
_recover_num_sinks
();
};
//
Constructor
template
<
typename
P,
typename
C>
inline
Topology::Topology
(Taskflow& tf, P&& p, C&& c):
_taskflow(tf),
_pred {std::forward<P>(p)},
_call {std::forward<C>(c)} {
}
//
Procedure: _bind
//
Re-builds the source links and the sink number for this topology.
inline
void
Topology::_bind
(Graph& g) {
_num_sinks =
0
;
_sources.
clear
();
//
scan each node in the graph and build up the links
for
(
auto
& node : g.
nodes
()) {
node->
_topology
=
this
;
if
(node->
num_dependents
() ==
0
) {
_sources.
push_back
(node.
get
());
}
if
(node->
num_successors
() ==
0
) {
_num_sinks++;
}
}
_cached_num_sinks = _num_sinks;
}
//
Procedure: _recover_num_sinks
inline
void
Topology::_recover_num_sinks
() {
_num_sinks = _cached_num_sinks;
}
}
//
end of namespace tf. ----------------------------------------------------
Back
|
FazBrowse Home
|
New Git URL