From 745e03b4fc1a0424bb0b472b6a50218138824a56 Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Sun, 5 Jan 2020 18:09:57 -0800 Subject: [PATCH] use c++11 thread local construct instead of boost --- moses2/System.cpp | 7 +++++-- moses2/System.h | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/moses2/System.cpp b/moses2/System.cpp index 63df967fe..6aef1ce86 100644 --- a/moses2/System.cpp +++ b/moses2/System.cpp @@ -20,6 +20,9 @@ using namespace std; namespace Moses2 { +thread_local MemPool System::m_managerPool; +thread_local MemPool System::m_systemPool; + System::System(const Parameter ¶msArg) : params(paramsArg), featureFunctions(*this) { @@ -163,12 +166,12 @@ void System::LoadDecodeGraphBackoff() MemPool &System::GetSystemPool() const { - return GetThreadSpecificObj(m_systemPool); + return m_systemPool; } MemPool &System::GetManagerPool() const { - return GetThreadSpecificObj(m_managerPool); + return m_managerPool; } FactorCollection &System::GetVocab() const diff --git a/moses2/System.h b/moses2/System.h index 1d60e96a0..ea356b706 100644 --- a/moses2/System.h +++ b/moses2/System.h @@ -65,11 +65,15 @@ public: protected: mutable FactorCollection m_vocab; - mutable boost::thread_specific_ptr m_managerPool; - mutable boost::thread_specific_ptr m_systemPool; + //mutable boost::thread_specific_ptr m_managerPool; + //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 MemPool d; + mutable boost::thread_specific_ptr m_batch; void LoadWeights();