diff --git a/moses2/System.cpp b/moses2/System.cpp index 6aef1ce86..fefb61ba4 100644 --- a/moses2/System.cpp +++ b/moses2/System.cpp @@ -22,6 +22,7 @@ namespace Moses2 thread_local MemPool System::m_managerPool; thread_local MemPool System::m_systemPool; +thread_local Recycler System::m_hypoRecycler; System::System(const Parameter ¶msArg) : params(paramsArg), featureFunctions(*this) @@ -181,7 +182,7 @@ FactorCollection &System::GetVocab() const Recycler &System::GetHypoRecycler() const { - return GetThreadSpecificObj(m_hypoRecycler); + return m_hypoRecycler; } Batch &System::GetBatch(MemPool &pool) const diff --git a/moses2/System.h b/moses2/System.h index ea356b706..732b2ed4d 100644 --- a/moses2/System.h +++ b/moses2/System.h @@ -69,8 +69,7 @@ protected: //mutable boost::thread_specific_ptr m_systemPool; thread_local static MemPool m_managerPool; thread_local static MemPool m_systemPool; - - mutable boost::thread_specific_ptr > m_hypoRecycler; + thread_local static Recycler m_hypoRecycler; //thread_local static MemPool d; diff --git a/moses2/legacy/Util2.h b/moses2/legacy/Util2.h index fe84cb039..3a5ad4719 100644 --- a/moses2/legacy/Util2.h +++ b/moses2/legacy/Util2.h @@ -311,20 +311,6 @@ void Swap(T &a, T &b) b = c; } -template -T &GetThreadSpecificObj(boost::thread_specific_ptr &coll) -{ - T *obj; - obj = coll.get(); - if (obj == NULL) { - obj = new T; - coll.reset(obj); - } - assert(obj); - return *obj; - -} - // grab the underlying contain of priority queue template S& Container(std::priority_queue& q)