void ximsWait() { OpStateVal oldOpState = OpState; UserSelection *sel = &userSel; struct timeval interval; time_t start_tm = 0; int lapse; DPR(("ximsWait(): OpState=%s OpErrCode=%s[%d]\n", StateName(), error_name(OpErrCode), OpErrCode)); OpState = State_Wait; if (oldOpState == State_Start_Err) { /* don't change OpErrCode */ OpState = State_Wait_Err; return; } if (!is_waiting() || (OpFlag & FLAG_NOWAIT)) { ximsWaitDone(); } if (im_mod_available(sel->renv) != 1) { if (useWINDOW()) { xt_start_waiting(); /* never returns unless failed */ } /* waiting */ lapse = 0; interval.tv_sec = Opt.Interval / 1000; interval.tv_usec = (Opt.Interval % 1000) * 1000; start_tm = time((time_t) 0); while (is_waiting()) { select(0, 0, 0, 0, &interval); /* usleep */ lapse = (int) time((time_t) 0) - start_tm; if (im_mod_available(sel->renv) != 0 || lapse >= Opt.Timeout) { DPR(("ximsWait(tmout=%d): wait done (%d sec.)\n", Opt.Timeout, lapse)); break; } } } ximsWaitDone(); }
void process(int thread_index) { (void)(thread_index); //currently unused, but maybe useful on debugging. for( ; ; ) { if(is_terminated()) { break; } task_ptr_t task = task_queue_.dequeue(); bool should_notify = false; task->run(); { task_count_lock_t lock(task_count_mutex_); --task_count_; if(is_waiting() && task_count_ == 0) { should_notify = true; } } if(should_notify) { c_task_.notify_all(); } } }
void process(int thread_index) { for( ; ; ) { if(is_terminated()) { break; } task_ptr_t task = task_queue_.dequeue(); bool should_notify = false; task->run(); { task_count_lock_t lock(task_count_mutex_); --task_count_; if(is_waiting() && task_count_ == 0) { should_notify = true; } } if(should_notify) { c_task_.notify_all(); } } }