STDMETHODIMP QAsyncReader::WaitForNext(DWORD timeout, IMediaSample **sample, DWORD_PTR *user) { QMutexLocker locker(&m_mutexWait); if (!sample ||!user) { return E_POINTER; } *sample = 0; *user = 0; AsyncRequest r = getNextRequest(); if (r.sample == 0) { //there is no request in the queue if (isFlushing()) { return VFW_E_WRONG_STATE; } else { //First we need to lock the mutex if (m_requestWait.wait(&m_mutexWait, timeout) == false) { return VFW_E_TIMEOUT; } if (isFlushing()) { return VFW_E_WRONG_STATE; } r = getNextRequest(); } } //at this point we're sure to have a request to proceed if (r.sample == 0) { return E_FAIL; } *sample = r.sample; *user = r.user; return SyncReadAligned(r.sample); }
int main( ) { Kern_Globals KERN_GLOBALS; // "Global" kernel structure initialize( &KERN_GLOBALS ); // includes starting the first user task int request; FOREVER { ++KERN_GLOBALS.profdata.kernel_loop_cnt; request = getNextRequest( &KERN_GLOBALS ); if ( request == SHUTDOWN_EVENT_SYSCALL ) return 0; handle_request( request, &KERN_GLOBALS ); // if( KERN_GLOBALS.scheduler.tasks_exited > 10 ) return 0; } }
void receiveCallback(int fd, short eventType, void* args) { struct worker* worker = args; struct request* request = getNextRequest(worker); if(request == NULL) { printf("Error: Tried to get a null request\n"); return; } struct timeval readTimestamp, timediff; gettimeofday(&readTimestamp, NULL); timersub(&readTimestamp, &(request->send_time), &timediff); double diff = timediff.tv_usec * 1e-6 + timediff.tv_sec; receiveResponse(request, diff); deleteRequest(request); worker->received_warmup_keys++; if(worker->config->pre_load == 1 && worker->config->dep_dist != NULL && worker->received_warmup_keys == worker->config->keysToPreload){ printf("You are warmed up, sir\n"); exit(0); } }//End receiveCallback()