|
SASC-NG
DVBSoftCAM
|
#include <thread.h>
Public Member Functions | |
| cCondVar (void) | |
| ~cCondVar () | |
| void | Wait (cMutex &Mutex) |
| bool | TimedWait (cMutex &Mutex, int TimeoutMs) |
| void | Broadcast (void) |
| cCondVar::cCondVar | ( | void | ) |
Definition at line 91 of file thread.cpp.
{
pthread_cond_init(&cond, 0);
}
| cCondVar::~cCondVar | ( | ) |
Definition at line 96 of file thread.cpp.
{
pthread_cond_broadcast(&cond); // wake up any sleepers
pthread_cond_destroy(&cond);
}
| void cCondVar::Broadcast | ( | void | ) |
Definition at line 131 of file thread.cpp.
Referenced by cSmartCardSlot::Action(), cMsgCache::Cache(), cDeCSA::Decrypt(), cSmartCardSlot::LockCard(), cCCcamCard::NewCw(), cCardClientCamd35::ProcessECM(), cCardClientCommon::ProcessECM(), cSmartCardSlot::ReleaseCard(), cTransponderTime::Set(), and cDeCSA::SetDescr().
{
pthread_cond_broadcast(&cond);
}
| bool cCondVar::TimedWait | ( | cMutex & | Mutex, |
| int | TimeoutMs | ||
| ) |
Definition at line 113 of file thread.cpp.
References GetAbsTime().
Referenced by cDeCSA::Decrypt(), cCCcamCard::GetCw(), cTransponderTime::Now(), cCardClientCCcam2::ProcessECM(), cCardClientCamd35::ProcessECM(), cCardClientCommon::ProcessECM(), and cDeCSA::SetDescr().
{
bool r = true; // true = condition signaled false = timeout
if (Mutex.locked) {
struct timespec abstime;
if (GetAbsTime(&abstime, TimeoutMs)) {
int locked = Mutex.locked;
Mutex.locked = 0; // have to clear the locked count here, as pthread_cond_timedwait
// does an implizit unlock of the mutex.
if (pthread_cond_timedwait(&cond, &Mutex.mutex, &abstime) == ETIMEDOUT)
r = false;
Mutex.locked = locked;
}
}
return r;
}
| void cCondVar::Wait | ( | cMutex & | Mutex | ) |
Definition at line 102 of file thread.cpp.
Referenced by cMsgCache::Get(), cSmartCardSlot::HaveCard(), cSmartCardSlot::LockCard(), cCardClientCamd35::ProcessECM(), and cCardClientCommon::ProcessECM().
{
if (Mutex.locked) {
int locked = Mutex.locked;
Mutex.locked = 0; // have to clear the locked count here, as pthread_cond_wait
// does an implizit unlock of the mutex
pthread_cond_wait(&cond, &Mutex.mutex);
Mutex.locked = locked;
}
}