示例#1
0
//START: ThreadStartsAfterStart
TEST(Thread, StartedThreadRunsBeforeItIsDestroyed)
{
    thread = Thread_Create(threadEntry, 0);
    Thread_Start(thread);
    Thread_Destroy(thread);
    CHECK(TRUE == threadRan);
}
示例#2
0
static void *
Thread_MainWrapper (void *arg) {
	struct Thread *l_pThread = (struct Thread *) arg;
	List_Lock(sg_threadList);
	Thread_Lock (l_pThread);

	l_pThread->bRunning = true;

	Thread_Unlock (l_pThread);
	List_Unlock(sg_threadList);

	l_pThread->mainFunction (l_pThread);

	List_Lock(sg_threadList);
	Thread_Lock (l_pThread);

	l_pThread->bRunning = false;

	Thread_Unlock (l_pThread);
	List_Unlock(sg_threadList);

	// Don't destroy the thread structure, it may still be referenced
	// We should probably ref count this struct
	Thread_Destroy(l_pThread);
	//
#ifdef _MSC_VER
	return 0;
#else //_MSC_VER
	return NULL; // Implicit pthread_exit()
#endif //_MSC_VER
}
示例#3
0
TEST(Thread, Join)
{
	void * result;
    thread = Thread_Create(threadEntry, 0);
    Thread_Start(thread);
    Thread_Join(thread, &result);
    Thread_Destroy(thread);
    LONGS_EQUAL(42, *((int *)result));
}