unsigned int getNext() { // no need to optimize this with atomics, it is only called ONCE per thread! mMutex.lock(); unsigned int val = mCounter++; mMutex.unlock(); return val; }
void unlockQueue() { if ( m_useSpinMutex ) { m_mutex.unlock(); } else { m_queueLock->unlock(); } }
static btVector4 selectColor2() { #ifdef BT_THREADSAFE static btSpinMutex sMutex; sMutex.lock(); #endif static int curColor = 0; btVector4 color = colors[curColor]; curColor++; curColor &= 3; #ifdef BT_THREADSAFE sMutex.unlock(); #endif return color; }