|
SASC
DVBSoftCAM
|
#include <thread.h>
Inheritance diagram for cRwLock:Public Member Functions | |
| cRwLock (bool PreferWriter=false) | |
| ~cRwLock () | |
| bool | Lock (bool Write, int TimeoutMs=0) |
| void | Unlock (void) |
| 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);
}
| 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 | ) |
Definition at line 166 of file thread.cpp.
Referenced by cCardClientCCcam2::CanHandle(), cShares::GetShares(), cStructLoader::ListUnlock(), cCardClientCCcam2::Logout(), cCardClientCCcam2::ProcessEMM(), and cShares::SetLag().
{
pthread_rwlock_unlock(&rwlock);
}