165 ARCCORE_DEFINE_REFERENCE_COUNTED_INCLASS_METHODS();
167 void addReference()
override { ReferenceCounterImpl::addReference(); }
168 void removeReference()
override { ReferenceCounterImpl::removeReference(); }
183 : m_use_tbb_barrier(
false)
186 if (!platform::getEnvironmentVariable(
"ARCANE_SPINLOCK_BARRIER").null())
187 m_use_tbb_barrier =
true;
188 m_std_thread_implementation = Arccore::Concurrency::createStdThreadImplementation();
194 GlobalMutex::destroy();
195 if (m_global_mutex_impl)
196 this->destroyMutex(m_global_mutex_impl);
205 void initialize()
override
207 m_global_mutex_impl = createMutex();
213 ThreadImpl* createThread(IFunctor* f)
override
215 return reinterpret_cast<ThreadImpl*
>(
new ThreadType(StartFunc(f)));
217 void joinThread(ThreadImpl* t)
override
219 ThreadType* tt =
reinterpret_cast<ThreadType*
>(t);
222 void destroyThread(ThreadImpl* t)
override
224 ThreadType* tt =
reinterpret_cast<ThreadType*
>(t);
228 void createSpinLock(
Int64* spin_lock_addr)
override
230 void* addr = spin_lock_addr;
231 new (addr) tbb::spin_mutex();
233 void lockSpinLock(
Int64* spin_lock_addr,
Int64* scoped_spin_lock_addr)
override
235 tbb::spin_mutex* s =
reinterpret_cast<tbb::spin_mutex*
>(spin_lock_addr);
236 tbb::spin_mutex::scoped_lock* sl =
new (scoped_spin_lock_addr) tbb::spin_mutex::scoped_lock();
239 void unlockSpinLock(
Int64* spin_lock_addr,
Int64* scoped_spin_lock_addr)
override
241 ARCANE_UNUSED(spin_lock_addr);
242 tbb::spin_mutex::scoped_lock* s =
reinterpret_cast<tbb::spin_mutex::scoped_lock*
>(scoped_spin_lock_addr);
247 MutexImpl* createMutex()
override
249 TBBMutexImpl* m =
new TBBMutexImpl();
250 return reinterpret_cast<MutexImpl*
>(m);
252 void destroyMutex(MutexImpl* mutex)
override
254 TBBMutexImpl* tm =
reinterpret_cast<TBBMutexImpl*
>(mutex);
257 void lockMutex(MutexImpl* mutex)
override
259 TBBMutexImpl* tm =
reinterpret_cast<TBBMutexImpl*
>(mutex);
262 void unlockMutex(MutexImpl* mutex)
override
264 TBBMutexImpl* tm =
reinterpret_cast<TBBMutexImpl*
>(mutex);
268 Int64 currentThread()
override
270 Int64 v = arcaneGetThisThreadId();
274 IThreadBarrier* createBarrier()
override
280 if (m_use_tbb_barrier)
281 return new TBBBarrier();
282 return m_std_thread_implementation->createBarrier();
287 bool m_use_tbb_barrier;
288 MutexImpl* m_global_mutex_impl;
289 Ref<IThreadImplementation> m_std_thread_implementation;