|
SASC-NG
DVBSoftCAM
|
#include <thread.h>
Public Member Functions | |
| cCondWait (void) | |
| ~cCondWait () | |
| bool | Wait (int TimeoutMs=0) |
| void | Signal (void) |
| Signals a caller of Wait() that the condition it is waiting for is met. | |
Static Public Member Functions | |
| static void | SleepMs (int TimeoutMs) |
| cCondWait::cCondWait | ( | void | ) |
Definition at line 39 of file thread.cpp.
References NULL.
| cCondWait::~cCondWait | ( | ) |
Definition at line 46 of file thread.cpp.
{
pthread_cond_broadcast(&cond); // wake up any sleepers
pthread_cond_destroy(&cond);
pthread_mutex_destroy(&mutex);
}
| void cCondWait::Signal | ( | void | ) |
Signals a caller of Wait() that the condition it is waiting for is met.
Definition at line 81 of file thread.cpp.
{
pthread_mutex_lock(&mutex);
signaled = true;
pthread_cond_broadcast(&cond);
pthread_mutex_unlock(&mutex);
}
| void cCondWait::SleepMs | ( | int | TimeoutMs | ) | [static] |
Creates a cCondWait object and uses it to sleep for TimeoutMs milliseconds, immediately giving up the calling thread's time slice and thus avoiding a "busy wait". In order to avoid a possible busy wait, TimeoutMs will be automatically limited to values >2.
Definition at line 53 of file thread.cpp.
Referenced by cSmartCardSlot::Action(), cScHousekeeper::Action(), cAction::Action(), cLogStats::Action(), cThread::Cancel(), cPipe::Close(), cSmartCardNagra::Decode(), cSmartCardSlotSerial::DeviceWrite(), cDeCsaTSBuffer::Get(), cSystemNagra2::ProcessECM(), cSystemNagra::ProcessECM(), cCam::Read(), cSmartCardSlot::Reset(), cThread::Start(), and cSmartCardNagra::Update().
| bool cCondWait::Wait | ( | int | TimeoutMs = 0 | ) |
Waits at most TimeoutMs milliseconds for a call to Signal(), or forever if TimeoutMs is 0.
Definition at line 59 of file thread.cpp.
References GetAbsTime().
Referenced by SleepMs().
{
pthread_mutex_lock(&mutex);
if (!signaled) {
if (TimeoutMs) {
struct timespec abstime;
if (GetAbsTime(&abstime, TimeoutMs)) {
while (!signaled) {
if (pthread_cond_timedwait(&cond, &mutex, &abstime) == ETIMEDOUT)
break;
}
}
}
else
pthread_cond_wait(&cond, &mutex);
}
bool r = signaled;
signaled = false;
pthread_mutex_unlock(&mutex);
return r;
}