SASC
DVBSoftCAM

cRwLock Class Reference

#include <thread.h>

Inheritance diagram for cRwLock:

List of all members.

Public Member Functions

 cRwLock (bool PreferWriter=false)
 ~cRwLock ()
bool Lock (bool Write, int TimeoutMs=0)
void Unlock (void)

Detailed Description

Definition at line 53 of file thread.h.


Constructor & Destructor Documentation

cRwLock::cRwLock ( bool  PreferWriter = false)

Definition at line 138 of file thread.cpp.

{
  pthread_rwlockattr_t attr;
  pthread_rwlockattr_init(&attr);
  pthread_rwlockattr_setkind_np(&attr, PreferWriter ? PTHREAD_RWLOCK_PREFER_WRITER_NP : PTHREAD_RWLOCK_PREFER_READER_NP);
  pthread_rwlock_init(&rwlock, &attr);
}
cRwLock::~cRwLock ( )

Definition at line 146 of file thread.cpp.

{
  pthread_rwlock_destroy(&rwlock);
}

Member Function Documentation

bool cRwLock::Lock ( bool  Write,
int  TimeoutMs = 0 
)

Definition at line 151 of file thread.cpp.

References GetAbsTime().

Referenced by cCardClientCCcam2::CanHandle(), cShares::GetShares(), cStructLoader::ListLock(), cCardClientCCcam2::Logout(), cCardClientCCcam2::ProcessEMM(), and cShares::SetLag().

{
  int Result = 0;
  struct timespec abstime;
  if (TimeoutMs) {
     if (!GetAbsTime(&abstime, TimeoutMs))
        TimeoutMs = 0;
     }
  if (Write)
     Result = TimeoutMs ? pthread_rwlock_timedwrlock(&rwlock, &abstime) : pthread_rwlock_wrlock(&rwlock);
  else
     Result = TimeoutMs ? pthread_rwlock_timedrdlock(&rwlock, &abstime) : pthread_rwlock_rdlock(&rwlock);
  return Result == 0;
}
void cRwLock::Unlock ( void  )

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