本文整理汇总了C++中Timeout类的典型用法代码示例。如果您正苦于以下问题:C++ Timeout类的具体用法?C++ Timeout怎么用?C++ Timeout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Timeout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InsertFront
void
TimeoutManager::Timeouts::Insert(Timeout* aTimeout, SortBy aSortBy)
{
// Start at mLastTimeout and go backwards. Stop if we see a Timeout with a
// valid FiringId since those timers are currently being processed by
// RunTimeout. This optimizes for the common case of insertion at the end.
Timeout* prevSibling;
for (prevSibling = GetLast();
prevSibling &&
// This condition needs to match the one in SetTimeoutOrInterval that
// determines whether to set When() or TimeRemaining().
(aSortBy == SortBy::TimeRemaining ?
prevSibling->TimeRemaining() > aTimeout->TimeRemaining() :
prevSibling->When() > aTimeout->When()) &&
// Check the firing ID last since it will evaluate true in the vast
// majority of cases.
mManager.IsInvalidFiringId(prevSibling->mFiringId);
prevSibling = prevSibling->getPrevious()) {
/* Do nothing; just searching */
}
// Now link in aTimeout after prevSibling.
if (prevSibling) {
prevSibling->setNext(aTimeout);
} else {
InsertFront(aTimeout);
}
aTimeout->mFiringId = InvalidFiringId;
}
示例2: lock_guard
bool
Rcu_data::do_batch()
{
int count = 0;
bool need_resched = false;
for (Rcu_list::Const_iterator l = _d.begin(); l != _d.end();)
{
Rcu_item *i = *l;
++l;
need_resched |= i->_call_back(i);
++count;
}
// XXX: I do not know why this and the former stuff is w/o cpu lock
// but the couting needs it ?
_d.clear();
// XXX: we use clear, we seemingly worked through the whole list
//_d.head(l);
{
auto guard = lock_guard(cpu_lock);
_len -= count;
}
#if 0
if (_d.full())
{
Timeout *t = &_rcu_timeout.cpu(_cpu);
t->set(t->get_timeout(0) + Rcu::Period, _cpu);
}
#endif
return need_resched;
}
示例3: setup
/**
* Application setup
*/
void setup()
{
bcu.begin(4, 0x7054, 2); // We are a "Jung 2118" device, version 0.2
pinMode(PIO_LED, OUTPUT);
digitalWrite(PIO_LED, 1);
// Configure the input pins and initialize the debouncers with the current
// value of the pin.
for (int channel = 0; channel < NUM_CHANNELS; ++channel)
{
pinMode(inputPins[channel], INPUT | HYSTERESIS | PULL_UP);
inputDebouncer[channel].init(digitalRead(inputPins[channel]));
}
// Handle configured power-up delay
unsigned int startupTimeout = calculateTime
( userEeprom[EE_BUS_RETURN_DELAY_BASE] >> 4
, userEeprom[EE_BUS_RETURN_DELAY_FACT] & 0x7F
);
Timeout delay;
int debounceTime = userEeprom[EE_INPUT_DEBOUNCE_TIME] >> 1;
delay.start(startupTimeout);
while (delay.started() && !delay.expired())
{ // while we wait for the power on delay to expire we debounce the input channels
for (int channel = 0; channel < NUM_CHANNELS; ++channel)
{
inputDebouncer[channel].debounce(digitalRead(inputPins[channel]), debounceTime);
}
waitForInterrupt();
}
initApplication();
}
示例4: WsfTimerUpdate
void BLE::callDispatcher()
{
// process the external event queue
_event_queue.process();
_last_update_us += (uint64_t)_timer.read_high_resolution_us();
_timer.reset();
uint64_t last_update_ms = (_last_update_us / 1000);
wsfTimerTicks_t wsf_ticks = (last_update_ms / WSF_MS_PER_TICK);
if (wsf_ticks > 0) {
WsfTimerUpdate(wsf_ticks);
_last_update_us -= (last_update_ms * 1000);
}
wsfOsDispatcher();
static Timeout nextTimeout;
CriticalSectionLock critical_section;
if (wsfOsReadyToSleep()) {
// setup an mbed timer for the next Cordio timeout
bool_t pTimerRunning;
timestamp_t nextTimestamp = (timestamp_t) (WsfTimerNextExpiration(&pTimerRunning) * WSF_MS_PER_TICK) * 1000;
if (pTimerRunning) {
nextTimeout.attach_us(timeoutCallback, nextTimestamp);
}
}
}
示例5: LYXERR
void LoaderQueue::startLoader()
{
LYXERR(Debug::GRAPHICS, "LoaderQueue: waking up");
running_ = true ;
timer.setTimeout(s_millisecs_);
timer.start();
}
示例6: InsertionPoint
void
TimeoutManager::Timeouts::Insert(Timeout* aTimeout, SortBy aSortBy)
{
// Start at mLastTimeout and go backwards. Don't go further than insertion
// point, though. This optimizes for the common case of insertion at the end.
Timeout* prevSibling;
for (prevSibling = GetLast();
prevSibling && prevSibling != InsertionPoint() &&
// This condition needs to match the one in SetTimeoutOrInterval that
// determines whether to set When() or TimeRemaining().
(aSortBy == SortBy::TimeRemaining ?
prevSibling->TimeRemaining() > aTimeout->TimeRemaining() :
prevSibling->When() > aTimeout->When());
prevSibling = prevSibling->getPrevious()) {
/* Do nothing; just searching */
}
// Now link in aTimeout after prevSibling.
if (prevSibling) {
prevSibling->setNext(aTimeout);
} else {
InsertFront(aTimeout);
}
aTimeout->mFiringDepth = 0;
// Increment the timeout's reference count since it's now held on to
// by the list
aTimeout->AddRef();
}
示例7:
// static
VOID CALLBACK Timeout::slot_timeout_win32( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime )
{
Timeout* timeout = s_timeouts[ idEvent ];
if( timeout != NULL ){
timeout->slot_timeout_callback();
}
}
示例8: while
void Timeout::check()
{
while (list && list->time <= rdtsc()) {
Timeout *t = list;
t->dequeue();
t->trigger();
}
}
示例9:
Timeout *Ev::BusDispatcher::add_timeout(Timeout::Internal *wi)
{
Timeout *t = new Ev::BusTimeout(wi, _loop, _priority);
debug_log("ev: added timeout %p (%s)", t, t->enabled() ? "on" : "off");
return t;
}
示例10:
Timeout *Ecore::BusDispatcher::add_timeout(Timeout::Internal *wi)
{
Timeout *t = new Ecore::BusTimeout(wi);
debug_log("ecore: added timeout %p (%s)", t, t->enabled() ? "on" : "off");
return t;
}
示例11: mypoll
inline int mypoll(MYPOLLFD *fds, unsigned int nfds, Timeout timeout){
fd_set readfd;
FD_ZERO(&readfd);
fd_set writefd;
FD_ZERO(&writefd);
fd_set oobfd;
FD_ZERO(&oobfd);
SOCKET maxfd = 0;
for (unsigned int i = 0; i < nfds; i++) {
if (fds[i].events & POLLIN) {
FD_SET(fds[i].fd, &readfd);
}
if (fds[i].events & POLLOUT) {
FD_SET(fds[i].fd, &writefd);
}
if (fds[i].events & POLLPRI) {
FD_SET(fds[i].fd, &oobfd);
}
fds[i].revents = 0;
if (fds[i].fd > maxfd) {
maxfd = fds[i].fd;
}
}
struct timeval tv;
tv.tv_sec = timeout.getSeconds();
tv.tv_usec = timeout.getMilliseconds() - (timeout.getSeconds() * 1000);
int num = select(((int)(maxfd)) + 1, &readfd, &writefd, &oobfd, &tv);
if (num < 1) {
return num;
}
for (unsigned int i = 0; i < nfds; i++) {
if (FD_ISSET(fds[i].fd, &readfd)) {
fds[i].revents |= POLLIN;
}
if (FD_ISSET(fds[i].fd, &writefd)) {
fds[i].revents |= POLLOUT;
}
if (FD_ISSET(fds[i].fd, &oobfd)) {
fds[i].revents |= POLLPRI;
}
}
return num;
}
示例12: ForEachUnorderedTimeoutAbortable
void
TimeoutManager::ClearTimeout(int32_t aTimerId, Timeout::Reason aReason)
{
uint32_t timerId = (uint32_t)aTimerId;
bool firstTimeout = true;
bool deferredDeletion = false;
ForEachUnorderedTimeoutAbortable([&](Timeout* aTimeout) {
MOZ_LOG(gLog, LogLevel::Debug,
("Clear%s(TimeoutManager=%p, timeout=%p, aTimerId=%u, ID=%u, tracking=%d)\n", aTimeout->mIsInterval ? "Interval" : "Timeout",
this, aTimeout, timerId, aTimeout->mTimeoutId,
int(aTimeout->mIsTracking)));
if (aTimeout->mTimeoutId == timerId && aTimeout->mReason == aReason) {
if (aTimeout->mRunning) {
/* We're running from inside the aTimeout. Mark this
aTimeout for deferred deletion by the code in
RunTimeout() */
aTimeout->mIsInterval = false;
deferredDeletion = true;
}
else {
/* Delete the aTimeout from the pending aTimeout list */
aTimeout->remove();
}
return true; // abort!
}
firstTimeout = false;
return false;
});
// We don't need to reschedule the executor if any of the following are true:
// * If the we weren't cancelling the first timeout, then the executor's
// state doesn't need to change. It will only reflect the next soonest
// Timeout.
// * If we did cancel the first Timeout, but its currently running, then
// RunTimeout() will handle rescheduling the executor.
// * If the window has become suspended then we should not start executing
// Timeouts.
if (!firstTimeout || deferredDeletion || mWindow.IsSuspended()) {
return;
}
// Stop the executor and restart it at the next soonest deadline.
mExecutor->Cancel();
OrderedTimeoutIterator iter(mNormalTimeouts, mTrackingTimeouts);
Timeout* nextTimeout = iter.Next();
if (nextTimeout) {
MOZ_ALWAYS_SUCCEEDS(MaybeSchedule(nextTimeout->When()));
}
}
示例13: app_start
void app_start(int, char*[]) {
MBED_HOSTTEST_TIMEOUT(10);
MBED_HOSTTEST_SELECT(default_auto);
MBED_HOSTTEST_DESCRIPTION(Sleep Timeout);
MBED_HOSTTEST_START("MBED_9");
led1 = 0;
led2 = 0;
led1_initial = led1;
led2_initial = led2;
to1.attach_us(led1_on, 1000000);
to2.attach_us(led2_on, 2000000);
}
示例14: callDispatcher
void BLE::waitForEvent()
{
static Timeout nextTimeout;
timestamp_t nextTimestamp;
bool_t pTimerRunning;
callDispatcher();
if (wsfOsReadyToSleep()) {
// setup an mbed timer for the next cordio timeout
nextTimestamp = (timestamp_t)(WsfTimerNextExpiration(&pTimerRunning) * WSF_MS_PER_TICK) * 1000;
if (pTimerRunning) {
nextTimeout.attach_us(timeoutCallback, nextTimestamp);
}
}
}
示例15: MY_Scene_Base
GameOver::GameOver(Game * _game, float _score) :
MY_Scene_Base(_game),
done(false)
{
std::string pic = "ENDING_";
if(_score > 300){
pic += "5";
}else if(_score > 200){
pic += "4";
}else if(_score > 125){
pic += "3";
}else if(_score > 50){
pic += "2";
}else{
pic += "1";
}
{
VerticalLinearLayout * vl = new VerticalLinearLayout(uiLayer->world);
uiLayer->addChild(vl);
vl->setRationalHeight(1.f, uiLayer);
vl->setRationalWidth(1.f, uiLayer);
vl->horizontalAlignment = kCENTER;
vl->verticalAlignment = kMIDDLE;
NodeUI * menu = new NodeUI(uiLayer->world);
vl->addChild(menu);
menu->setRationalHeight(1.f, vl);
menu->setSquareWidth(1.f);
menu->background->mesh->pushTexture2D(MY_ResourceManager::globalAssets->getTexture(pic)->texture);
menu->background->mesh->setScaleMode(GL_NEAREST);
}
Timeout * doneTimeout = new Timeout(0.5f, [this](sweet::Event * _event){
done = true;
NodeUI * n = new NodeUI(uiLayer->world);
n->setRationalHeight(1.f, uiLayer);
n->setRationalWidth(1.f, uiLayer);
uiLayer->addChild(n);
n->background->mesh->pushTexture2D(MY_ResourceManager::globalAssets->getTexture("CLICK")->texture);
n->background->mesh->setScaleMode(GL_NEAREST);
});
doneTimeout->start();
doneTimeout->name = "done timeout";
childTransform->addChild(doneTimeout, false);
}