本文整理汇总了C++中OsTime::isInfinite方法的典型用法代码示例。如果您正苦于以下问题:C++ OsTime::isInfinite方法的具体用法?C++ OsTime::isInfinite怎么用?C++ OsTime::isInfinite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsTime
的用法示例。
在下文中一共展示了OsTime::isInfinite方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: acquire
// Block the task until the mutex is acquired or the timeout expires
OsStatus OsMutexLinux::acquire(const OsTime& rTimeout)
{
struct timespec timeout;
OsStatus status;
if(rTimeout.isInfinite())
{
status = (pt_mutex_lock(&mMutexImp) == POSIX_OK) ? OS_SUCCESS : OS_BUSY;
}
else if(rTimeout.isNoWait())
{
status = (pt_mutex_trylock(&mMutexImp) == POSIX_OK) ? OS_SUCCESS : OS_BUSY;
}
else
{
OsUtilLinux::cvtOsTimeToTimespec(rTimeout, &timeout);
status = (pt_mutex_timedlock(&mMutexImp, &timeout) == POSIX_OK)
? OS_SUCCESS : OS_WAIT_TIMEOUT;
}
#ifdef OS_SYNC_DEBUG
if (status == OS_SUCCESS)
{
mSyncCrumbs.dropCrumb(pthread_self(), crumbAcquired);
}
#endif
return status;
}
示例2: acquire
// Block the task until the semaphore is acquired or the timeout expires
OsStatus OsCSemLinux::acquire(const OsTime& rTimeout)
{
struct timespec timeout;
OsStatus res;
if (rTimeout.isInfinite())
res = (pt_sem_wait(&mSemImp) == POSIX_OK) ? OS_SUCCESS : OS_BUSY;
else if (rTimeout.isNoWait())
res = (pt_sem_trywait(&mSemImp) == POSIX_OK) ? OS_SUCCESS : OS_BUSY;
else
{
OsUtilLinux::cvtOsTimeToTimespec(rTimeout, &timeout);
res = (pt_sem_timedwait(&mSemImp, &timeout) == POSIX_OK) ? OS_SUCCESS : OS_WAIT_TIMEOUT;
}
#ifdef OS_CSEM_DEBUG
if (res == OS_SUCCESS)
{
updateAcquireStats();
}
#endif
#ifdef OS_SYNC_DEBUG
if (res == OS_SUCCESS)
{
mSyncCrumbs.dropCrumb(pthread_self(), crumbAcquired);
}
#endif
return res;
}
示例3: enableTimer
// Enable the repeat timer for the designated button.
// A write lock should be acquired before calling this method.
void PsButtonTask::enableTimer(int index)
{
// OsQueuedEvent* pNotifier;
OsTime repInterval;
OsStatus res;
if (mpRepTimers[index] != NULL) // if there already is a repeat timer,
disableTimer(index); // disable it
mpButtonInfo[index].getRepInterval(repInterval);
if (repInterval.isInfinite()) // if the repeat interval is infinite,
return; // don't bother enabling it
mpRepTimers[index] = new OsTimer(&mIncomingQ, index);
res = mpRepTimers[index]->periodicEvery(repInterval, repInterval);
assert(res == OS_SUCCESS);
}
示例4: synchObjAcquire
// Block the task until the synch obj is acquired or the timeout expires
OsStatus OsUtilWnt::synchObjAcquire(const HANDLE synchObj,
const OsTime& rTimeout)
{
DWORD ntRes;
DWORD msecsTimer;
OsStatus res;
if (rTimeout.isInfinite())
msecsTimer = INFINITE;
else
{
assert(OsUtilWnt::isOsTimeValid(rTimeout));
msecsTimer = OsUtilWnt::cvtOsTimeToWntTime(rTimeout);
}
ntRes = WaitForSingleObject(synchObj, msecsTimer);
switch (ntRes)
{
case 0:
res = OS_SUCCESS;
break;
case WAIT_TIMEOUT:
res = OS_WAIT_TIMEOUT;
break;
case WAIT_ABANDONED:
res = OS_WAIT_ABANDONED;
break;
default:
/*
osPrintf(
"OsUtilWnt::synchObjAcquire: WaitForSingleObject() returned %d,\n"
" GetLastError() = %d"
"\n\n", ntRes, GetLastError());
*/
res = OS_UNSPECIFIED;
break;
}
return res;
}
示例5: doReceive
// Helper function for removing a message from the head of the queue
OsStatus OsMsgQShared::doReceive(OsMsg*& rpMsg, const OsTime& rTimeout)
{
OsStatus ret;
if (!rTimeout.isInfinite())
{
int expireFromNow = rTimeout.cvtToMsecs();
if (try_dequeue(rpMsg, expireFromNow))
ret = OS_SUCCESS;
else
ret = OS_WAIT_TIMEOUT;
}
else
{
dequeue(rpMsg);
ret = OS_SUCCESS;
}
system_tap_queue_dequeue(mName.data(), 0, _queue.size());
return ret;
}