File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010
1111#include < functional>
1212#include < memory>
13+ #include < mutex>
1314
1415#include " tbb/concurrent_vector.h"
1516
@@ -36,8 +37,9 @@ class ContinuationInput
3637 template <typename F>
3738 void Add (F&& input)
3839 {
39- if (bufferedInputsPtr_ == nullptr )
40- bufferedInputsPtr_ = std::unique_ptr<InputVectT>(new InputVectT ());
40+ std::call_once (bufferedInputsInit_, [this ] {
41+ bufferedInputsPtr_.reset (new InputVectT ());
42+ });
4143 bufferedInputsPtr_->push_back (std::forward<F>(input));
4244 }
4345
@@ -52,7 +54,8 @@ class ContinuationInput
5254 }
5355
5456private:
55- std::unique_ptr<InputVectT> bufferedInputsPtr_ = nullptr ;
57+ std::once_flag bufferedInputsInit_;
58+ std::unique_ptr<InputVectT> bufferedInputsPtr_ = nullptr ;
5659};
5760
5861/* ***************************************/ REACT_IMPL_END /* **************************************/
You can’t perform that action at this time.
0 commit comments