SASC-NG
DVBSoftCAM

cCondVar Class Reference

#include <thread.h>

List of all members.

Public Member Functions

 cCondVar (void)
 ~cCondVar ()
void Wait (cMutex &Mutex)
bool TimedWait (cMutex &Mutex, int TimeoutMs)
void Broadcast (void)

Detailed Description

Definition at line 42 of file thread.h.


Constructor & Destructor Documentation

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);
}

Member Function Documentation

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;
     }
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines