/** * Leave a level of model loads in the current thread. * If it was the last level, call the global callbacks. */ void PostLoadCallBack::leave() { threadsLock_.grab(); bool wasLastLevel = (--threads_[OurThreadID()].enterCount == 0); threadsLock_.give(); if (wasLastLevel) run( true ); }
LONG WINAPI CrashExceptionFilter( struct _EXCEPTION_POINTERS *ExceptionInfo ) { // Mutex here due to http://www.jenkinssoftware.com/raknet/forum/index.php?topic=2305.0;topicseen static SimpleMutex crashExceptionFilterMutex; crashExceptionFilterMutex.Lock(); LONG retVal = ProcessException(ExceptionInfo); crashExceptionFilterMutex.Unlock(); return retVal; }
void LintelLog::maybeInitInstance() { static SimpleMutex init_mutex; // is this actually safe? Really don't want to have to take the // lock when we almost never need to. if (instance == NULL) { init_mutex.lock(); if (instance == NULL) { instance_data *tmp = new instance_data(); tmp->mutex.lock(); // try to force the above to be tmp->mutex.unlock(); instance = tmp; } init_mutex.unlock(); } }
/** * This method runs all callbacks from one of the lists */ void PostLoadCallBack::run( bool global ) { SimpleMutexHolder smh( threadsLock_ ); std::vector< PostLoadCallBack * > * cbs; PLCBs & plcbs = threads_[OurThreadID()]; cbs = global ? &plcbs.globals : &plcbs.locals; while (!cbs->empty()) { PostLoadCallBack * lf = cbs->front(); cbs->erase( cbs->begin() ); threadsLock_.give(); (*lf)(); delete lf; threadsLock_.grab(); PLCBs & plcbs = threads_[OurThreadID()]; cbs = global ? &plcbs.globals : &plcbs.locals; } }
RemapLock::~RemapLock() { _remapLock.unlock(); }
RemapLock::RemapLock() { _remapLock.lock(); }
SimpleThreadLock::SimpleThreadLock(SimpleMutex &mutex) : m_mutex(mutex), m_locked(true) { mutex.lock(); }
void RakString::UnlockMutex(void) { poolMutex.Unlock(); }
void RakString::LockMutex(void) { poolMutex.Lock(); }