164 ARCCORE_DEFINE_REFERENCE_COUNTED_INCLASS_METHODS();
166 void addReference()
override { ReferenceCounterImpl::addReference(); }
167 void removeReference()
override { ReferenceCounterImpl::removeReference(); }
182 : m_use_tbb_barrier(
false)
185 if (!platform::getEnvironmentVariable(
"ARCANE_SPINLOCK_BARRIER").null())
186 m_use_tbb_barrier =
true;
187 m_std_thread_implementation = Arccore::Concurrency::createStdThreadImplementation();
193 GlobalMutex::destroy();
194 if (m_global_mutex_impl)
195 this->destroyMutex(m_global_mutex_impl);
204 void initialize()
override
206 m_global_mutex_impl = createMutex();
212 ThreadImpl* createThread(IFunctor* f)
override
214 return reinterpret_cast<ThreadImpl*
>(
new ThreadType(StartFunc(f)));
216 void joinThread(ThreadImpl* t)
override
218 ThreadType* tt =
reinterpret_cast<ThreadType*
>(t);
221 void destroyThread(ThreadImpl* t)
override
223 ThreadType* tt =
reinterpret_cast<ThreadType*
>(t);
227 void createSpinLock(
Int64* spin_lock_addr)
override
229 void* addr = spin_lock_addr;
230 new (addr) tbb::spin_mutex();
232 void lockSpinLock(
Int64* spin_lock_addr,
Int64* scoped_spin_lock_addr)
override
234 tbb::spin_mutex* s =
reinterpret_cast<tbb::spin_mutex*
>(spin_lock_addr);
235 tbb::spin_mutex::scoped_lock* sl =
new (scoped_spin_lock_addr) tbb::spin_mutex::scoped_lock();
238 void unlockSpinLock(
Int64* spin_lock_addr,
Int64* scoped_spin_lock_addr)
override
240 ARCANE_UNUSED(spin_lock_addr);
241 tbb::spin_mutex::scoped_lock* s =
reinterpret_cast<tbb::spin_mutex::scoped_lock*
>(scoped_spin_lock_addr);
246 MutexImpl* createMutex()
override
248 TBBMutexImpl* m =
new TBBMutexImpl();
249 return reinterpret_cast<MutexImpl*
>(m);
251 void destroyMutex(MutexImpl* mutex)
override
253 TBBMutexImpl* tm =
reinterpret_cast<TBBMutexImpl*
>(mutex);
256 void lockMutex(MutexImpl* mutex)
override
258 TBBMutexImpl* tm =
reinterpret_cast<TBBMutexImpl*
>(mutex);
261 void unlockMutex(MutexImpl* mutex)
override
263 TBBMutexImpl* tm =
reinterpret_cast<TBBMutexImpl*
>(mutex);
267 Int64 currentThread()
override
269 Int64 v = arcaneGetThisThreadId();
273 IThreadBarrier* createBarrier()
override
279 if (m_use_tbb_barrier)
280 return new TBBBarrier();
281 return m_std_thread_implementation->createBarrier();
286 bool m_use_tbb_barrier;
287 MutexImpl* m_global_mutex_impl;
288 Ref<IThreadImplementation> m_std_thread_implementation;