3#ifndef OSL_LIGHT_MUTEX_H
4#define OSL_LIGHT_MUTEX_H
8# include "osl/misc/perfmon.h"
17#if defined OSL_USE_RACE_DETECTOR || defined _MSC_VER
18 typedef std::mutex LightMutex;
19 typedef std::mutex LightMutexChar;
21 template <
class Mutex>
33 if(!
m.waitLock(100))
break;
34 if(
m.tryLock())
return;
37 std::this_thread::yield();
61 if(
data!=0)
return false;
64 asm __volatile__(
" movl $1,%0" "\n\t"
65 " xchgl (%1),%0" "\n\t"
70# error "not supported"
75 for(
int i=0;i<counter;i++){
77 asm __volatile__(
" pause" "\n\t");
90 std::this_thread::yield();
130 if(
data!=0)
return false;
133 asm __volatile__(
" movb $1,%0" "\n\t"
134 " xchgb (%1),%0" "\n\t"
139# error "not supported"
144 for(
int i=0;i<counter;i++){
146 asm __volatile__(
" pause" "\n\t");
155 for(
int i=0;i<2;i++){
159 std::this_thread::yield();
169# define SCOPED_LOCK(lock,m) \
170 static osl::misc::CounterPair c(__FILE__, __FUNCTION__, __LINE__); \
171 osl::misc::LightMutex::scoped_lock lock(c,m);
172# define SCOPED_LOCK_CHAR(lock,m) \
173 static osl::misc::CounterPair c(__FILE__, __FUNCTION__, __LINE__); \
174 osl::misc::LightMutexChar::scoped_lock lock(c,m);
176# define SCOPED_LOCK(lock,m) \
177 osl::misc::LightMutex::scoped_lock lock(m);
178# define SCOPED_LOCK_CHAR(lock,m) \
179 osl::misc::LightMutexChar::scoped_lock lock(m);
182 using misc::LightMutex;
LightMutexChar(const LightMutexChar &)=delete
LightMutexChar & operator=(const LightMutexChar &)=delete
LightScopedLock< LightMutexChar > scoped_lock
bool waitLock(int counter)
requirement: thread local
unlockable_lock(LightMutex &m)
unlockable_lock & operator=(const unlockable_lock &)
unlockable_lock(const unlockable_lock &)
LightMutex(const LightMutex &)=delete
bool waitLock(int counter)
LightScopedLock< LightMutex > scoped_lock
LightMutex & operator=(const LightMutex &)=delete
LightScopedLock & operator=(const LightScopedLock &)=delete
LightScopedLock(Mutex &m)
LightScopedLock(const LightScopedLock &)=delete