Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6e67b08

Browse files
committed
Merge branch 'master' of https://github.com/taskflow/taskflow
2 parents a24896d + 0334c52 commit 6e67b08

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

taskflow/core/graph.hpp

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ class Node {
213213

214214
std::string _name;
215215

216+
void* _data {nullptr};
217+
216218
handle_t _handle;
217219

218220
SmallVector<Node*> _successors;
@@ -224,15 +226,10 @@ class Node {
224226

225227
Node* _parent {nullptr};
226228

227-
//int _state {0};
228229
std::atomic<int> _state {0};
229-
230230
std::atomic<size_t> _join_counter {0};
231231

232232
void _precede(Node*);
233-
//void _set_state(int);
234-
//void _unset_state(int);
235-
//void _clear_state();
236233
void _set_up_join_counter();
237234

238235
bool _has_state(int) const;
@@ -415,26 +412,6 @@ inline const std::string& Node::name() const {
415412
return _name;
416413
}
417414

418-
//// Procedure: _set_state
419-
//inline void Node::_set_state(int flag) {
420-
// _state |= flag;
421-
//}
422-
//
423-
//// Procedure: _unset_state
424-
//inline void Node::_unset_state(int flag) {
425-
// _state &= ~flag;
426-
//}
427-
//
428-
//// Procedure: _clear_state
429-
//inline void Node::_clear_state() {
430-
// _state = 0;
431-
//}
432-
//
433-
//// Function: _has_state
434-
//inline bool Node::_has_state(int flag) const {
435-
// return _state & flag;
436-
//}
437-
438415
// Function: _is_cancelled
439416
inline bool Node::_is_cancelled() const {
440417
if(_handle.index() == Node::ASYNC) {
@@ -535,7 +512,6 @@ inline void Graph::clear() {
535512
inline void Graph::clear_detached() {
536513

537514
auto mid = std::partition(_nodes.begin(), _nodes.end(), [] (Node* node) {
538-
//return !(node->_has_state(Node::DETACHED));
539515
return !(node->_state.load(std::memory_order_relaxed) & Node::DETACHED);
540516
});
541517

taskflow/core/task.hpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,20 @@ class Task {
311311
*/
312312
void dump(std::ostream& ostream) const;
313313

314+
/**
315+
@brief queries pointer to user data
316+
*/
317+
void* data() const;
318+
319+
/**
320+
@brief assigns pointer to user data
321+
322+
@param data pointer to user data
323+
324+
@return @c *this
325+
*/
326+
Task& data(void* data);
327+
314328
private:
315329

316330
Task(Node*);
@@ -507,6 +521,17 @@ Task& Task::work(C&& c) {
507521
return *this;
508522
}
509523

524+
// Function: name
525+
inline void* Task::data() const {
526+
return _node->_data;
527+
}
528+
529+
// Function: name
530+
inline Task& Task::data(void* data) {
531+
_node->_data = data;
532+
return *this;
533+
}
534+
510535
// ----------------------------------------------------------------------------
511536
// global ostream
512537
// ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)