File tree Expand file tree Collapse file tree 4 files changed +20
-20
lines changed
Expand file tree Collapse file tree 4 files changed +20
-20
lines changed Original file line number Diff line number Diff line change @@ -637,7 +637,12 @@ inline void Executor::_invoke(unsigned me, Node* node) {
637637
638638 // Clear the subgraph before the task execution
639639 if (!node->is_spawned ()) {
640- node->_subgraph .emplace ();
640+ if (node->_subgraph ) {
641+ node->_subgraph ->clear ();
642+ }
643+ else {
644+ node->_subgraph .emplace ();
645+ }
641646 }
642647
643648 Subflow fb (*(node->_subgraph ));
@@ -668,7 +673,7 @@ inline void Executor::_invoke(unsigned me, Node* node) {
668673
669674 _schedule (src);
670675
671- if (! fb.detached ()) {
676+ if (fb.joined ()) {
672677 return ;
673678 }
674679 }
@@ -682,7 +687,7 @@ inline void Executor::_invoke(unsigned me, Node* node) {
682687 if (!node->is_subtask ()) {
683688 // Only dynamic tasking needs to restore _dependents
684689 // TODO:
685- if (node->_work .index () == 1 && !node->_subgraph ->empty ()) {
690+ if (node->_work .index () == 1 && !node->_subgraph ->empty ()) {
686691 while (!node->_dependents .empty () && node->_dependents .back ()->is_subtask ()) {
687692 node->_dependents .pop_back ();
688693 }
Original file line number Diff line number Diff line change @@ -259,7 +259,7 @@ inline Graph& Graph::operator = (Graph&& other) {
259259// clear and recycle the nodes
260260inline void Graph::clear () {
261261 for (auto & node : _nodes) {
262- NodePool.enstack (std::move (node));
262+ NodePool.release (std::move (node));
263263 }
264264 _nodes.clear ();
265265}
@@ -294,10 +294,7 @@ inline const std::vector<std::unique_ptr<Node>>& Graph::nodes() const {
294294// create a node from a give argument; constructor is called if necessary
295295template <typename ... ArgsT>
296296Node& Graph::emplace_back (ArgsT&&... args) {
297- // _nodes.push_back(
298- // per_thread_object_pool<Node>().get(std::forward<ArgsT>(args)...)
299- // );
300- _nodes.push_back (NodePool.destack (std::forward<ArgsT>(args)...));
297+ _nodes.push_back (NodePool.acquire (std::forward<ArgsT>(args)...));
301298 return *(_nodes.back ());
302299}
303300
Original file line number Diff line number Diff line change @@ -27,10 +27,10 @@ class ObjectPool {
2727
2828 size_t size () const ;
2929
30- void enstack (std::unique_ptr<T>&& obj);
30+ void release (std::unique_ptr<T>&& obj);
3131
3232 template <typename ... ArgsT>
33- std::unique_ptr<T> destack (ArgsT&&... args);
33+ std::unique_ptr<T> acquire (ArgsT&&... args);
3434
3535 private:
3636
@@ -56,10 +56,10 @@ size_t ObjectPool<T>::size() const {
5656 return _stack.size ();
5757}
5858
59- // Function: destack
59+ // Function: acquire
6060template <typename T>
6161template <typename ... ArgsT>
62- std::unique_ptr<T> ObjectPool<T>::destack (ArgsT&&... args) {
62+ std::unique_ptr<T> ObjectPool<T>::acquire (ArgsT&&... args) {
6363 if (_stack.empty ()) {
6464 return std::make_unique<T>(std::forward<ArgsT>(args)...);
6565 }
@@ -71,13 +71,11 @@ std::unique_ptr<T> ObjectPool<T>::destack(ArgsT&&... args) {
7171 }
7272}
7373
74- // Procedure: enstack
74+ // Procedure: release
7575template <typename T>
76- void ObjectPool<T>::enstack(std::unique_ptr<T>&& obj) {
77- if (_stack.size () < 4096 ) {
78- obj->recycle ();
79- _stack.push_back (std::move (obj));
80- }
76+ void ObjectPool<T>::release(std::unique_ptr<T>&& obj) {
77+ obj->recycle ();
78+ _stack.push_back (std::move (obj));
8179}
8280
8381} // end of namespace tf -----------------------------------------------------
Original file line number Diff line number Diff line change @@ -224,7 +224,7 @@ TEST_CASE("ObjectPool" * doctest::timeout(300)) {
224224 break ;
225225 }
226226 else {
227- auto ptr = TestObjectPool.destack (c);
227+ auto ptr = TestObjectPool.acquire (c);
228228 std::scoped_lock lock (mutex);
229229 objects.push_back (std::move (ptr));
230230 }
@@ -254,7 +254,7 @@ TEST_CASE("ObjectPool" * doctest::timeout(300)) {
254254 else {
255255 std::scoped_lock lock (mutex);
256256 REQUIRE (!objects.empty ());
257- TestObjectPool.enstack (std::move (objects.back ()));
257+ TestObjectPool.release (std::move (objects.back ()));
258258 objects.pop_back ();
259259 }
260260 }
You can’t perform that action at this time.
0 commit comments