本文整理汇总了C++中Timer::Cancel方法的典型用法代码示例。如果您正苦于以下问题:C++ Timer::Cancel方法的具体用法?C++ Timer::Cancel怎么用?C++ Timer::Cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer
的用法示例。
在下文中一共展示了Timer::Cancel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
CCOspApplication::OnBackground(void)
{
Timer* timer = CCEGLView::sharedOpenGLView()->getTimer();
if (timer != null)
{
timer->Cancel();
}
}
示例2: Calibrate
void MicrosecondTimer::Calibrate()
{
iCount = 0;
Expired();
iExpired = false;
while(!iExpired) {
}
iExpired = false;
while(!iExpired) {
iCount++;
}
iTimer.Cancel();
}
示例3: Cancel
/**
* Destructor. Discards any pending events.
*/
~RateLimiter() {
Cancel();
}
示例4: sys_ppoll
int sys_ppoll(struct pollfd* user_fds, size_t nfds,
const struct timespec* user_timeout_ts,
const sigset_t* user_sigmask)
{
ioctx_t ctx; SetupKernelIOCtx(&ctx);
struct timespec timeout_ts;
if ( !FetchTimespec(&timeout_ts, user_timeout_ts) )
return -1;
if ( user_sigmask )
return errno = ENOSYS, -1;
struct pollfd* fds = CopyFdsFromUser(user_fds, nfds);
if ( !fds ) { return -1; }
PollNode* nodes = new PollNode[nfds];
if ( !nodes ) { delete[] fds; return -1; }
Process* process = CurrentProcess();
kthread_mutex_t wakeup_mutex = KTHREAD_MUTEX_INITIALIZER;
kthread_cond_t wakeup_cond = KTHREAD_COND_INITIALIZER;
kthread_mutex_lock(&wakeup_mutex);
int ret = -1;
bool self_woken = false;
bool remote_woken = false;
bool unexpected_error = false;
Timer timer;
struct poll_timeout pts;
if ( timespec_le(timespec_make(0, 1), timeout_ts) )
{
timer.Attach(Time::GetClock(CLOCK_MONOTONIC));
struct itimerspec its;
its.it_interval = timespec_nul();
its.it_value = timeout_ts;
pts.wake_mutex = &wakeup_mutex;
pts.wake_cond = &wakeup_cond;
pts.woken = &remote_woken;
timer.Set(&its, NULL, 0, poll_timeout_callback, &pts);
}
size_t reqs;
for ( reqs = 0; !unexpected_error && reqs < nfds; )
{
PollNode* node = nodes + reqs;
if ( fds[reqs].fd < 0 )
{
fds[reqs].revents = POLLNVAL;
// TODO: Should we set POLLNVAL in node->revents too? Should this
// system call ignore this error and keep polling, or return to
// user-space immediately? What if conditions are already true on
// some of the file descriptors (those we have processed so far?)?
node->revents = 0;
reqs++;
continue;
}
Ref<Descriptor> desc = process->GetDescriptor(fds[reqs].fd);
if ( !desc ) { self_woken = unexpected_error = true; break; }
node->events = fds[reqs].events | POLL__ONLY_REVENTS;
node->revents = 0;
node->wake_mutex = &wakeup_mutex;
node->wake_cond = &wakeup_cond;
node->woken = &remote_woken;
reqs++;
// TODO: How should errors be handled?
if ( desc->poll(&ctx, node) == 0 )
self_woken = true;
else if ( errno == EAGAIN )
errno = 0;
else
unexpected_error = self_woken = true;
}
if ( timeout_ts.tv_sec == 0 && timeout_ts.tv_nsec == 0 )
self_woken = true;
while ( !(self_woken || remote_woken) )
{
if ( !kthread_cond_wait_signal(&wakeup_cond, &wakeup_mutex) )
errno = -EINTR,
self_woken = true;
}
kthread_mutex_unlock(&wakeup_mutex);
for ( size_t i = 0; i < reqs; i++ )
if ( 0 <= fds[i].fd )
nodes[i].Cancel();
if ( timespec_le(timespec_make(0, 1), timeout_ts) )
{
timer.Cancel();
timer.Detach();
}
if ( !unexpected_error )
//.........这里部分代码省略.........