dispenso
A library for task parallelism
 
Loading...
Searching...
No Matches
dispenso::Node Class Reference

#include <graph.h>

Inherited by dispenso::BiPropNode.

Public Member Functions

 Node (const Node &)=delete
 
Nodeoperator= (const Node &)=delete
 
 Node (Node &&other) noexcept
 
template<typename... Ns>
void dependsOn (Ns &... nodes)
 
void run () const
 
template<class F >
void forEachDependent (F &&func) const
 
template<class F >
void forEachDependent (F &&func)
 
size_t numPredecessors () const
 
bool isCompleted () const
 
bool setIncomplete () const
 
void setCompleted () const
 

Protected Member Functions

template<class F , class X = std::enable_if_t<!std::is_base_of<Node, F>::value, void>>
 Node (F &&f)
 
void dependsOnOneNode (Node &node)
 

Protected Attributes

std::atomic< size_tnumIncompletePredecessors_
 
size_t numPredecessors_ = 0
 

Static Protected Attributes

static constexpr size_t kCompleted = std::numeric_limits<size_t>::max()
 

Friends

template<class N >
class SubgraphT
 
template<typename G >
void setAllNodesIncomplete (const G &graph)
 

Detailed Description

Class to store task with dependencies

Definition at line 221 of file graph.h.

Constructor & Destructor Documentation

◆ Node() [1/2]

dispenso::Node::Node ( Node &&  other)
inlinenoexcept

Definition at line 226 of file graph.h.

◆ ~Node()

dispenso::Node::~Node ( )
inline

Definition at line 235 of file graph.h.

◆ Node() [2/2]

template<class F , class X = std::enable_if_t<!std::is_base_of<Node, F>::value, void>>
dispenso::Node::Node ( F &&  f)
inlineprotected

Definition at line 320 of file graph.h.

Member Function Documentation

◆ dependsOn()

template<typename... Ns>
void dispenso::Node::dependsOn ( Ns &...  nodes)
inline

Make this node depends on nodes. This is not concurrency safe.

Parameters
nodespredecessors of the node

Definition at line 246 of file graph.h.

◆ dependsOnOneNode()

void dispenso::Node::dependsOnOneNode ( Node node)
inlineprotected

Definition at line 330 of file graph.h.

◆ forEachDependent() [1/2]

template<class F >
void dispenso::Node::forEachDependent ( F &&  func)
inline

apply an func to each dependent of the node This is not concurrency safe.

Parameters
funca functor with signature void(Node&)

Definition at line 274 of file graph.h.

◆ forEachDependent() [2/2]

template<class F >
void dispenso::Node::forEachDependent ( F &&  func) const
inline

apply an func to each dependent of the node

Parameters
funca functor with signature void(const Node&)

Definition at line 263 of file graph.h.

◆ isCompleted()

bool dispenso::Node::isCompleted ( ) const
inline

Return true if node is completed. New node always incomplete. If node was invoked it become completed. this state can be changed by calling setIncomplete() Concurrency safe.

Definition at line 291 of file graph.h.

◆ numPredecessors()

size_t dispenso::Node::numPredecessors ( ) const
inline

Return the number of nodes this node depends on. Concurrency safe.

Definition at line 282 of file graph.h.

◆ run()

void dispenso::Node::run ( ) const
inline

Invoke the type-erased functor. Change competed state of the node to "Incomplete". Concurrency safe.

Definition at line 253 of file graph.h.

◆ setCompleted()

void dispenso::Node::setCompleted ( ) const
inline

Mark node completed. Concurrency safe. This methods should never be called concurrent to when the graph execution is happening

Definition at line 314 of file graph.h.

◆ setIncomplete()

bool dispenso::Node::setIncomplete ( ) const
inline

Mark node incomplete. (that allows reevaluate this node again). Concurrency safe. This methods should never be called concurrent to when the graph execution is happening

Returns
true if state was changed.

Definition at line 301 of file graph.h.

Friends And Related Symbol Documentation

◆ setAllNodesIncomplete

template<typename G >
void setAllNodesIncomplete ( const G graph)
friend

Definition at line 93 of file graph_executor.cpp.

◆ SubgraphT

template<class N >
friend class SubgraphT
friend

Definition at line 349 of file graph.h.

Member Data Documentation

◆ kCompleted

constexpr size_t dispenso::Node::kCompleted = std::numeric_limits<size_t>::max()
staticconstexprprotected

Definition at line 335 of file graph.h.

◆ numIncompletePredecessors_

std::atomic<size_t> dispenso::Node::numIncompletePredecessors_
mutableprotected

Definition at line 336 of file graph.h.

◆ numPredecessors_

size_t dispenso::Node::numPredecessors_ = 0
protected

Definition at line 337 of file graph.h.


The documentation for this class was generated from the following file: