本文整理汇总了C++中Timeout类的典型用法代码示例。如果您正苦于以下问题:C++ Timeout类的具体用法?C++ Timeout怎么用?C++ Timeout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Timeout类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:marcoscaceres,项目名称:gecko-dev,代码行数:31,代码来源:TimeoutManager.cpp
示例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;
}
开发者ID:TUM-LIS,项目名称:optimsoc-fiasco,代码行数:34,代码来源:rcupdate.cpp
示例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();
}
开发者ID:glueckm,项目名称:software-arm-incubation,代码行数:37,代码来源:app_main.cpp
示例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);
}
}
}
开发者ID:donatieng,项目名称:mbed,代码行数:31,代码来源:CordioBLE.cpp
示例5: LYXERR
void LoaderQueue::startLoader()
{
LYXERR(Debug::GRAPHICS, "LoaderQueue: waking up");
running_ = true ;
timer.setTimeout(s_millisecs_);
timer.start();
}
开发者ID:maxvas,项目名称:SciLyx,代码行数:7,代码来源:GraphicsLoader.cpp
示例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();
}
开发者ID:,项目名称:,代码行数:30,代码来源:
示例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();
}
}
开发者ID:shinnya,项目名称:jd-mirror,代码行数:8,代码来源:timeout.cpp
示例8: while
void Timeout::check()
{
while (list && list->time <= rdtsc()) {
Timeout *t = list;
t->dequeue();
t->trigger();
}
}
开发者ID:OakDevel,项目名称:NOVA,代码行数:8,代码来源:timeout.cpp
示例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;
}
开发者ID:elvischen,项目名称:live-streamer,代码行数:8,代码来源:dbusxx-libev-integration.cpp
示例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;
}
开发者ID:PDXostc,项目名称:navit,代码行数:8,代码来源:ecore-integration.cpp
示例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;
}
开发者ID:darkpixel93,项目名称:flatworm,代码行数:57,代码来源:NetUtils.cpp
示例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()));
}
}
开发者ID:marcoscaceres,项目名称:gecko-dev,代码行数:55,代码来源:TimeoutManager.cpp
示例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);
}
开发者ID:0xc0170,项目名称:mbed-drivers,代码行数:12,代码来源:main.cpp
示例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);
}
}
}
开发者ID:donatieng,项目名称:mbed,代码行数:16,代码来源:CordioBLE.cpp
示例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);
}
开发者ID:seleb,项目名称:LOWREZJAM-2,代码行数:47,代码来源:GameOver.cpp
示例16: sleep
bool ThreadSleeper::sleep(Timeout timeout) {
if (timeout.isInfinite()) {
sem_wait(&semaphore);
} else {
timespec tmspc = timeout.getExpireTime().getTimeSpec();
int res = sem_timedwait(&semaphore,&tmspc);
if (res == -1) {
int e = errno;
if (e == ETIMEDOUT) return true;
if (e != EINTR) throw ErrNoException(THISLOCATION,e);
//Consider EINTR as wakeUp
return false;
}
}
while (sem_trywait(&semaphore) == 0) {}
return false;
}
开发者ID:xsmart,项目名称:lightspeed,代码行数:17,代码来源:threadSleeper.cpp
示例17: GetMaxBudget
void
TimeoutManager::UpdateBackgroundState()
{
mExecutionBudget = GetMaxBudget(mWindow.IsBackgroundInternal());
// When the window moves to the background or foreground we should
// reschedule the TimeoutExecutor in case the MinSchedulingDelay()
// changed. Only do this if the window is not suspended and we
// actually have a timeout.
if (!mWindow.IsSuspended()) {
OrderedTimeoutIterator iter(mNormalTimeouts, mTrackingTimeouts);
Timeout* nextTimeout = iter.Next();
if (nextTimeout) {
mExecutor->Cancel();
MOZ_ALWAYS_SUCCEEDS(MaybeSchedule(nextTimeout->When()));
}
}
}
开发者ID:marcoscaceres,项目名称:gecko-dev,代码行数:18,代码来源:TimeoutManager.cpp
示例18: MOZ_LOG
void
TimeoutManager::Resume()
{
MOZ_LOG(gLog, LogLevel::Debug,
("Resume(TimeoutManager=%p)\n", this));
// When Suspend() has been called after IsDocumentLoaded(), but the
// throttle tracking timer never managed to fire, start the timer
// again.
if (mWindow.AsInner()->IsDocumentLoaded() && !mThrottleTimeouts) {
MaybeStartThrottleTimeout();
}
OrderedTimeoutIterator iter(mNormalTimeouts, mTrackingTimeouts);
Timeout* nextTimeout = iter.Next();
if (nextTimeout) {
MOZ_ALWAYS_SUCCEEDS(MaybeSchedule(nextTimeout->When()));
}
}
开发者ID:marcoscaceres,项目名称:gecko-dev,代码行数:19,代码来源:TimeoutManager.cpp
示例19: main
int main()
{
Threat threat = Threat(0);
Timeout loopTimeout = Timeout(40);
// game loop
while (1) {
loopTimeout.start();
string enemy1; // name of enemy 1
cin >> enemy1; cin.ignore();
int dist1; // distance to enemy 1
cin >> dist1; cin.ignore();
threat.push_back(Enemy(dist1, enemy1));
string enemy2; // name of enemy 2
cin >> enemy2; cin.ignore();
int dist2; // distance to enemy 2
cin >> dist2; cin.ignore();
threat.push_back(Enemy(dist2, enemy2));
// We have acquired the list of enemy
// We have to sort the list from the
// closest to far away
sort(threat.begin(), threat.end(),
[](const Enemy & a, const Enemy & b)
{
// true will make the sort to let
// the object in the same order
return a.getDist() < b.getDist();
});
// We acquire the enemy which is the closer,
// ie at the end of the list of threat
Enemy threatToEliminate = threat.front();
threat.erase(threat.begin());
// We output the enemy to kill
cout << threatToEliminate.getName() << endl;
if(loopTimeout.hasTimedOut()) break;
}
return EXIT_SUCCESS;
}
开发者ID:EramoxPersonalWork,项目名称:CodinGame,代码行数:43,代码来源:main.cpp
示例20: equeue_sema_wait
bool equeue_sema_wait(equeue_sema_t *s, int ms) {
int signal = 0;
Timeout timeout;
if (ms > 0) {
timeout.attach_us(callback(equeue_sema_timeout, s), ms*1000);
}
core_util_critical_section_enter();
while (!*s) {
sleep();
core_util_critical_section_exit();
core_util_critical_section_enter();
}
signal = *s;
*s = false;
core_util_critical_section_exit();
return (signal > 0);
}
开发者ID:anangl,项目名称:mbed-os,代码行数:20,代码来源:equeue_mbed.cpp
注:本文中的Timeout类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论