Range<AsyncIO::Op**> AsyncIO::wait(size_t minRequests) { CHECK(ctx_); CHECK_EQ(pollFd_, -1) << "wait() only allowed on non-pollable object"; auto p = pending_.load(std::memory_order_acquire); CHECK_LE(minRequests, p); return doWait(minRequests, p); }
//============================================================================= // METHOD : SPELLcontroller::executionLock //============================================================================= void SPELLcontroller::executionLock() { if (m_abort) doWait(); DEBUG("[C] Controller process lock"); notifyBeforeDriverOperation(); m_controllerLock.clear(); }
void Condition::wait(NonRecursiveMutexLock& lock) { if (!lock.isLocked()) { OW_THROW(ConditionLockException, "Lock must be locked"); } doWait(*(lock.m_mutex)); }
natural HttpClient::BufferedNetworkStream::wait(natural waitFor, natural timeout) const { if ((waitFor & waitForInput) && this->dataReady()) return waitForInput; if ((waitFor & waitForOutput) && this->getWriteSpace()>0) return waitForOutput; WaitHandler *wh = getWaitHandler(); if (wh) { return wh->wait(this,waitFor,timeout); } else { return doWait(waitFor,timeout); } }
Range<AsyncIO::Op**> AsyncIO::pollCompleted() { CHECK(ctx_); CHECK_NE(pollFd_, -1) << "pollCompleted() only allowed on pollable object"; uint64_t numEvents; // This sets the eventFd counter to 0, see // http://www.kernel.org/doc/man-pages/online/pages/man2/eventfd.2.html ssize_t rc; do { rc = ::read(pollFd_, &numEvents, 8); } while (rc == -1 && errno == EINTR); if (UNLIKELY(rc == -1 && errno == EAGAIN)) { return Range<Op**>(); // nothing completed } checkUnixError(rc, "AsyncIO: read from event fd failed"); DCHECK_EQ(rc, 8); DCHECK_GT(numEvents, 0); DCHECK_LE(numEvents, pending_); // Don't reap more than numEvents, as we've just reset the counter to 0. return doWait(numEvents, numEvents); }
void showMsgPaused(char* str) { showMsg(str); doWait(); }
Range<AsyncIO::Op**> AsyncIO::wait(size_t minRequests) { CHECK(ctx_); CHECK_EQ(pollFd_, -1) << "wait() only allowed on non-pollable object"; CHECK_LE(minRequests, pending_); return doWait(minRequests, pending_); }
void BulletMLRunnerImpl::runWait() { int frame = static_cast<int>(getNumberContents(act_)); doWait(frame); act_ = 0; }
void ObjectSelector::run(){ //ulong crttout; int state; int pollwait = 0; const int maxnbcnt = 256; int nbcnt = -1;//non blocking opperations count //used to reduce the number of calls for the system time. do{ state = 0; if(nbcnt < 0){ d.ctimepos.currentRealTime(); nbcnt = maxnbcnt; } if(d.ctimepos > d.ntimepos){ state |= Data::FULL_SCAN; } if(state || d.objq.size()){ pollwait = 0; --nbcnt; }else{ if(d.ntimepos.seconds() != 0xffffffff) { pollwait = 1; }else pollwait = -1; nbcnt = -1; } state |= doWait(pollwait); if(state & Data::FULL_SCAN){ idbgx(Debug::frame, "full_scan"); ulong evs = 0; d.ntimepos.set(0xffffffff); for(Data::ObjectStubVectorT::iterator it(d.sv.begin()); it != d.sv.end(); it += 4){ if(!it->objptr.empty()){ Data::ObjectStub &ro = *it; evs = 0; if(d.ctimepos >= ro.timepos) evs |= EventTimeout; else if(d.ntimepos > ro.timepos) d.ntimepos = ro.timepos; if(ro.objptr->notified(S_RAISE)) evs |= EventSignal;//should not be checked by objs if(evs){ state |= doExecute(it - d.sv.begin(), evs, d.ctimepos); } } if(!(it + 1)->objptr.empty()){ Data::ObjectStub &ro = *(it + 1); evs = 0; if(d.ctimepos >= ro.timepos) evs |= EventTimeout; else if(d.ntimepos > ro.timepos) d.ntimepos = ro.timepos; if(ro.objptr->notified(S_RAISE)) evs |= EventSignal;//should not be checked by objs if(evs){ state |= doExecute(it - d.sv.begin() + 1, evs, d.ctimepos); } } if(!(it + 2)->objptr.empty()){ Data::ObjectStub &ro = *(it + 2); evs = 0; if(d.ctimepos >= ro.timepos) evs |= EventTimeout; else if(d.ntimepos > ro.timepos) d.ntimepos = ro.timepos; if(ro.objptr->notified(S_RAISE)) evs |= EventSignal;//should not be checked by objs if(evs){ state |= doExecute(it - d.sv.begin() + 2, evs, d.ctimepos); } } if(!(it + 3)->objptr.empty()){ Data::ObjectStub &ro = *(it + 3); evs = 0; if(d.ctimepos >= ro.timepos) evs |= EventTimeout; else if(d.ntimepos > ro.timepos) d.ntimepos = ro.timepos; if(ro.objptr->notified(S_RAISE)) evs |= EventSignal;//should not be checked by objs if(evs){ state |= doExecute(it - d.sv.begin() + 3, evs, d.ctimepos); } } } } { int qsz = d.objq.size(); while(qsz){//we only do a single scan: vdbgx(Debug::frame, "qsz = "<<qsz<<" queuesz "<<d.objq.size()); int pos = d.objq.front();d.objq.pop(); --qsz; Data::ObjectStub &ro = d.sv[pos]; if(ro.state){ ro.state = 0; state |= doExecute(pos, 0, d.ctimepos); } } } vdbgx(Debug::frame, "sz = "<<d.sz); if(empty()) state |= Data::EXIT_LOOP; }while(state != Data::EXIT_LOOP); }
/*! execute action */ bool Bhv_GoalieFreeKick::execute( rcsc::PlayerAgent * agent ) { static bool s_first_move = false; static bool s_second_move = false; static int s_second_wait_count = 0; rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Bhf_GoalieFreeKick" ); if ( agent->world().gameMode().type() != rcsc::GameMode::GoalieCatch_ || agent->world().gameMode().side() != agent->world().ourSide() || ! agent->world().self().isKickable() ) { rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Bhv_GoalieFreeKick. Not a goalie catch mode" ); Bhv_GoalieBasicMove().execute( agent ); return true; } const long time_diff = agent->world().time().cycle() - agent->effector().getCatchTime().cycle(); //- M_catch_time.cycle(); // reset flags & wait if ( time_diff <= 2 ) { s_first_move = false; s_second_move = false; s_second_wait_count = 0; doWait( agent ); return true; } // first move if ( ! s_first_move ) { //rcsc::Vector2D move_target( rcsc::ServerParam::i().ourPenaltyAreaLine() - 0.8, 0.0 ); rcsc::Vector2D move_target( rcsc::ServerParam::i().ourPenaltyAreaLineX() - 1.5, agent->world().ball().pos().y > 0.0 ? -17.0 : 17.0 ); //rcsc::Vector2D move_target( -45.0, 0.0 ); s_first_move = true; s_second_move = false; s_second_wait_count = 0; agent->doMove( move_target.x, move_target.y ); agent->setNeckAction( new rcsc::Neck_ScanField ); return true; } // after first move // check stamina recovery or wait teammate rcsc::Rect2D our_pen( rcsc::Vector2D( -52.5, -40.0 ), rcsc::Vector2D( -36.0, 40.0 ) ); if ( time_diff < 50 || agent->world().setplayCount() < 3 || ( time_diff < rcsc::ServerParam::i().dropBallTime() - 15 && ( agent->world().self().stamina() < rcsc::ServerParam::i().staminaMax() * 0.9 || agent->world().existTeammateIn( our_pen, 20, true ) ) ) ) { doWait( agent ); return true; } // second move if ( ! s_second_move ) { rcsc::Vector2D kick_point = getKickPoint( agent ); agent->doMove( kick_point.x, kick_point.y ); agent->setNeckAction( new rcsc::Neck_ScanField ); s_second_move = true; s_second_wait_count = 0; return true; } s_second_wait_count++; // after second move // wait see info if ( s_second_wait_count < 5 || agent->world().seeTime() != agent->world().time() ) { doWait( agent ); return true; } s_first_move = false; s_second_move = false; s_second_wait_count = 0; // register kick intention doKick( agent ); return true; }