bool CVideoDevice::BeginDraw(CDirectxBase* newFocus, ID3D10Device1*& pDevice, Locker& devLock) { devLock.set(m_drawLock); devLock.lock(); pDevice = m_pDevice; bool bFocusChange = m_currentFocus != newFocus; m_currentFocus = newFocus; return bFocusChange; }
void CondVar::wait(Locker &l) { Service *pService = Service::getFiberService(); if (pService) { l.unlock(); m_blocks.put(pService->m_running); pService->switchtonext(); l.lock(); } }
//MultThread Insert void* thread_insert(void *arg) { printf("thread_insert....\n"); //printf("thread_insert pid is %lu\n",(unsigned long)pthread_self()); Locker* testLock = (Locker *)arg; testLock->lock(testLock); //pthread_mutex_lock(&mylock); if(0 == gddlink_update) { pthread_cond_signal(&cond); } gddlink_update=1; InsertDDLink(&L,&num[global_count%10]); printf("Insert element %d\n",num[global_count%10]); //pthread_mutex_unlock(&mylock); testLock->unlock(testLock); //return &estatus; pthread_exit(NULL); }
//MultThread Display void* thread_display(void *arg) { printf("thread_dispaly....\n"); //printf("thread_dispaly pid is %lu\n",(unsigned long)pthread_self()); //pthread_mutex_lock(&mylock); Locker* testLock = (Locker *)arg; testLock->lock(testLock); while(0 == gddlink_update) { //pthread_cond_wait(&cond, &mylock); pthread_cond_wait(&cond, testLock->getlock(testLock)); } gddlink_update=0; //printf("Disply DDLink,Global is %d\n",global_count); DDLinkForeach(&L, DDLinkForeachPrint,print_int); //pthread_mutex_unlock(&mylock); testLock->unlock(testLock); printf("\n"); //return &estatus; pthread_exit(NULL); }