void * _glfwNewThread( void * arg )
{
    GLFWthreadfun threadfun;
    _GLFWthread   *t;

    // Get pointer to thread information for current thread
    t = _glfwGetThreadPointer( glfwGetThreadID() );
    if( t == NULL )
    {
        return 0;
    }

    // Get user thread function pointer
    threadfun = t->Function;

    // Call the user thread function
    threadfun( arg );

    // Remove thread from thread list
    ENTER_THREAD_CRITICAL_SECTION
        _glfwRemoveThread( t );
    LEAVE_THREAD_CRITICAL_SECTION

    // When the thread function returns, the thread will die...
    return NULL;
}
Пример #2
0
LockID Thread_Manager::EnterLock(int mutexID) {
#ifndef _WIN32
	ThreadID Cur = glfwGetThreadID();
	mutexNumLocks[Cur][mutexID]++;
	if(mutexNumLocks[Cur][mutexID] == 1)
	{
		glfwLockMutex(mutexLocks[mutexID]);
	}
#else
	glfwLockMutex(mutexLocks[mutexID]);
#endif
	return mutexID;
}
Пример #3
0
void Thread_Manager::LeaveLock(LockID lockID) {
#ifndef _WIN32
	ThreadID Cur = glfwGetThreadID();
	mutexNumLocks[Cur][lockID]--;
	if(mutexNumLocks[Cur][lockID] == 0) {
		glfwUnlockMutex(mutexLocks[lockID]);
	}
	if(mutexNumLocks[Cur][lockID] < 0) {
		logWrite("FATAL ERROR: Mutex %d was unlocked more times than it was locked!", lockID);
	}
#else
	glfwUnlockMutex(mutexLocks[lockID]);
#endif
}
Пример #4
0
ThreadID Thread_Manager::GetCurrentThreadID() {
	return glfwGetThreadID();
}