TEST(CLConditionVariable, Multi_process_for_Shared_Cond) { CLSharedMemory *psm = new CLSharedMemory("test_for_multi_process_for_shared_cond", 16); long *p = (long *)(psm->GetAddress()); *p = 0; long *flag = (long *)(((char *)p) + 8); *flag = 0; CLEvent event("test_for_event_auto"); CLProcess *process = new CLProcess(new CLProcessFunctionForExec); EXPECT_TRUE(process->Run((void *)"../test_for_exec/test_for_CLConditionVariable/main").IsSuccess()); CLMutex mutex("mutex_for_test_for_multi_process_for_shared_cond", MUTEX_USE_SHARED_PTHREAD); CLConditionVariable cv("test_conditoin_variable_for_multiprocess"); { CLCriticalSection cs(&mutex); while(*flag == 0) EXPECT_TRUE((cv.Wait(&mutex)).IsSuccess()); } EXPECT_EQ(*p, 5); EXPECT_TRUE(event.Wait().IsSuccess()); delete psm; }
virtual CLStatus Initialize(CLMessageLoopManager *pMessageLoop, void* pContext) { pMessageLoop->Register(1, (CallBackForMessageLoop)(&CLStressObserverForCLNonThreadForMsgLoop_Process::On_1)); CLProcess *process = new CLProcess(new CLProcessFunctionForExec, false); EXPECT_TRUE((process->Run((void *)"../test_for_exec/test_for_CLNonThreadForMsgLoop_Stress_Testing/main")).IsSuccess()); return CLStatus(0, 0); }