Mixe for Privacy and Anonymity in the Internet
Public Member Functions | Protected Attributes | Friends | List of all members
CAMutex Class Reference

#include <CAMutex.hpp>

Inheritance diagram for CAMutex:
Collaboration diagram for CAMutex:

Public Member Functions

 CAMutex ()
 
virtual ~CAMutex ()
 
SINT32 lock ()
 
SINT32 unlock ()
 

Protected Attributes

CASemaphore * m_pMutex
 

Friends

class CAConditionVariable
 

Detailed Description

Definition at line 35 of file CAMutex.hpp.

Constructor & Destructor Documentation

◆ CAMutex()

CAMutex::CAMutex ( )

Definition at line 33 of file CAMutex.cpp.

34 {
35  #ifdef HAVE_PTHREAD_MUTEXES
36  m_pMutex=new pthread_mutex_t;
37  //m_pMutexAttributes = new pthread_mutexattr_t;
38  //pthread_mutexattr_init(m_pMutexAttributes);
39  //pthread_mutexattr_settype(m_pMutexAttributes, PTHREAD_MUTEX_RECURSIVE);
40  //pthread_mutexattr_settype(m_pMutexAttributes, PTHREAD_MUTEX_ERRORCHECK);
41  //pthread_mutex_init(m_pMutex, m_pMutexAttributes);
42  pthread_mutex_init(m_pMutex, NULL);
43  #else
44  m_pMutex=new CASemaphore(1);
45  #endif
46 }
CASemaphore * m_pMutex
Definition: CAMutex.hpp:69

References m_pMutex.

Referenced by CAConditionVariable::CAConditionVariable().

Here is the caller graph for this function:

◆ ~CAMutex()

CAMutex::~CAMutex ( )
virtual

Definition at line 48 of file CAMutex.cpp.

49 {
50  #ifdef HAVE_PTHREAD_MUTEXES
51  pthread_mutex_destroy(m_pMutex);
52  //pthread_mutexattr_destroy(m_pMutexAttributes);
53  #endif
54  delete m_pMutex;
55  m_pMutex = NULL;
56 
57  #ifdef HAVE_PTHREAD_MUTEXES
58  //delete m_pMutexAttributes;
59  #endif
60 }

References m_pMutex.

Member Function Documentation

◆ lock()

SINT32 CAMutex::lock ( )
inline

Definition at line 41 of file CAMutex.hpp.

42  {
43  #ifdef HAVE_PTHREAD_MUTEXES
44  if(pthread_mutex_lock(m_pMutex)==0)
45  return E_SUCCESS;
46  return E_UNKNOWN;
47  #else
48  return m_pMutex->down();
49  #endif
50  }
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2
#define E_UNKNOWN
Definition: errorcodes.hpp:3

References E_SUCCESS, E_UNKNOWN, and m_pMutex.

Referenced by CAAccountingInstance::__newSettlementTransaction(), CASocket::accept(), CASocketGroupEpoll::add(), CASocketList::add(), CACacheLoadBalancing::add(), CAQueue::add(), CALastMixBChannelList::add(), CAFirstMixChannelToQueueList::add(), CAMiddleMixChannelList::add(), CASocketGroup::add(), CAFirstMixChannelList::addChannel(), CAThreadPool::addRequest(), CASocketList::addSendMeCounter(), CACryptoBenchmark::benchmarkThread(), CAConditionVariable::broadcast(), CAMuxSocket::CAMuxSocket(), CATempIPBlockList::checkIP(), CAAccountingDBInterface::checkOwner(), CACacheLoadBalancing::clean(), CAQueue::clean(), CATempIPBlockList::cleanupThreadMainLoop(), CAQueue::close(), CASocket::close(), CASocket::create(), CAChainTable::createEntry(), CAFirstMixChannelList::decDelayBuckets(), CAFirstMix::decNewConnections(), CAControlChannelDispatcher::decryptMessage(), CAFirstMix::decUsers(), CAControlChannelDispatcher::deleteAllControlChannels(), CAChainTable::deleteEntry(), CAThreadPool::destroy(), CAControlChannelDispatcher::encryptMessage(), CAAccountingInstance::finishLoginProcess(), CAFirstMixChannelList::forceKickout(), CACacheLoadBalancing::get(), CAFirstMixChannelList::get(), CALastMixBChannelList::get(), CAFirstMixChannelToQueueList::get(), CASocketList::get(), CAQueue::get(), tUINT32withLock::getAndzero(), CAAccountingDBInterface::getConnection(), CAChainTable::getEntry(), CAFirstMixChannelList::getFirst(), CAChainTable::getFirstEntry(), CASocketAddrINet::getHostName(), CAMiddleMixChannelList::getInToOut(), CASocketAddrINet::getLocalHostIP(), CASocketAddrINet::getLocalHostName(), CAFirstMixChannelList::getNext(), CAChainTable::getNextEntry(), CAAccountingInstance::getNrOfUsers(), CAQueue::getOrWait(), CAMiddleMixChannelList::getOutToIn(), CAQueue::getSize(), CAChainTable::getSize(), CAAccountingInstance::handleAccountCertificate_internal(), CAAccountingInstance::handleChallengeResponse_internal(), CAAccountingInstance::handleCostConfirmation_internal(), CAAccountingInstance::handleJapPacket_internal(), CAFirstMixChannelList::hasDelayBuckets(), tUINT32withLock::inc(), CAFirstMix::incMixedPackets(), CAFirstMix::incNewConnections(), CAFirstMix::incUsers(), CAInfoService::InfoLoop(), CAReplayDatabase::insert(), CADatabase::insert(), CAIPList::insertIP(), CATempIPBlockList::insertIP(), CAFirstMixChannelList::isKickoutForced(), isLoginOngoing(), CAFirstMixChannelList::isTimedOut(), CALockAble::lock(), CAAccountingInstance::loginProcessStatus(), CAFirstMixA::loop(), CAAccountingSettleThread::mainLoop(), CADatabase::nextClock(), CAReplayDatabase::nextClock(), CALibProxytest::openssl_locking_callback(), parseDOMDocument(), CAQueue::peek(), CAMuxSocket::prepareForSend(), CAMsg::printMsg(), CAControlChannelDispatcher::proccessMixPacket(), CAAccountingInstance::processJapMessageLoginHelper(), CAAccountingInstance::processThread(), CAFirstMixChannelList::pushTimeoutEntry(), CAThreadList::put(), CAMuxSocket::receive(), CAControlChannelDispatcher::registerControlChannel(), CAAccountingDBInterface::releaseConnection(), releaseDOMParser(), CAFirstMixChannelList::remove(), CASocketGroup::remove(), CASocketGroupEpoll::remove(), CAThreadList::remove(), CAMiddleMixChannelList::remove(), CASocketList::remove(), CAQueue::remove(), CAFirstMixChannelList::removeChannel(), CAFirstMixChannelToQueueList::removeChannel(), CAControlChannelDispatcher::removeControlChannel(), CALastMixBChannelList::removeFromTable(), CAIPList::removeIP(), resetLoginOngoing(), CASocketGroup::select(), CASocketGroupEpoll::select(), CAMuxSocket::send(), CAControlChannelDispatcher::sendMessages(), CASocketAddrINet::setAddr(), CAMuxSocket::setCrypt(), CAFirstMixChannelList::setDelayParameters(), CAFirstMixChannelList::setKickoutForced(), CAAccountingInstance::setPrepaidBytesToZero(), CAAccountingSettleThread::settle(), CAAccountingInstance::settlementTransaction(), CAThreadList::showAll(), CAConditionVariable::signal(), CAInfoService::signal(), CADatabase::simulateInsert(), CAReplayDatabase::simulateInsert(), CAInfoService::stop(), CAAccountingDBInterface::testAndResetOwner(), testAndSetLoginOwner(), CAAccountingDBInterface::testAndSetOwner(), testLoginEntryOwner(), CALockAble::unlock(), CAConditionVariable::wait(), CALockAble::waitForDestroy(), CAAccountingInstance::~CAAccountingInstance(), CADatabase::~CADatabase(), CAMiddleMixChannelList::~CAMiddleMixChannelList(), CAMuxSocket::~CAMuxSocket(), CAReplayDatabase::~CAReplayDatabase(), CATempIPBlockList::~CATempIPBlockList(), and CAThreadList::~CAThreadList().

◆ unlock()

SINT32 CAMutex::unlock ( )
inline

Definition at line 52 of file CAMutex.hpp.

53  {
54  #ifdef HAVE_PTHREAD_MUTEXES
55  if(pthread_mutex_unlock(m_pMutex)==0)
56  return E_SUCCESS;
57  return E_UNKNOWN;
58  #else
59  return m_pMutex->up();
60  #endif
61  }

References E_SUCCESS, E_UNKNOWN, and m_pMutex.

Referenced by CAAccountingInstance::__newSettlementTransaction(), CASocket::accept(), CASocketGroupEpoll::add(), CASocketList::add(), CACacheLoadBalancing::add(), CAQueue::add(), CALastMixBChannelList::add(), CAFirstMixChannelToQueueList::add(), CAMiddleMixChannelList::add(), CASocketGroup::add(), CAFirstMixChannelList::addChannel(), CAThreadPool::addRequest(), CASocketList::addSendMeCounter(), CACryptoBenchmark::benchmarkThread(), CAConditionVariable::broadcast(), CAMuxSocket::CAMuxSocket(), CATempIPBlockList::checkIP(), CAAccountingDBInterface::checkOwner(), CACacheLoadBalancing::clean(), CAQueue::clean(), CATempIPBlockList::cleanupThreadMainLoop(), CAQueue::close(), CASocket::close(), CASocket::create(), CAChainTable::createEntry(), CAFirstMixChannelList::decDelayBuckets(), CAFirstMix::decNewConnections(), CAControlChannelDispatcher::decryptMessage(), CAFirstMix::decUsers(), CAControlChannelDispatcher::deleteAllControlChannels(), CAChainTable::deleteEntry(), CAThreadPool::destroy(), CAControlChannelDispatcher::encryptMessage(), CAAccountingInstance::finishLoginProcess(), CAFirstMixChannelList::forceKickout(), CACacheLoadBalancing::get(), CAFirstMixChannelList::get(), CALastMixBChannelList::get(), CAFirstMixChannelToQueueList::get(), CASocketList::get(), CAQueue::get(), tUINT32withLock::getAndzero(), CAAccountingDBInterface::getConnection(), CAChainTable::getEntry(), CAFirstMixChannelList::getFirst(), CAChainTable::getFirstEntry(), CASocketAddrINet::getHostName(), CAMiddleMixChannelList::getInToOut(), CASocketAddrINet::getLocalHostIP(), CASocketAddrINet::getLocalHostName(), CAFirstMixChannelList::getNext(), CAChainTable::getNextEntry(), CAAccountingInstance::getNrOfUsers(), CAQueue::getOrWait(), CAMiddleMixChannelList::getOutToIn(), CAQueue::getSize(), CAChainTable::getSize(), CAAccountingInstance::handleAccountCertificate_internal(), CAAccountingInstance::handleChallengeResponse_internal(), CAAccountingInstance::handleCostConfirmation_internal(), CAAccountingInstance::handleJapPacket_internal(), CAFirstMixChannelList::hasDelayBuckets(), tUINT32withLock::inc(), CAFirstMix::incMixedPackets(), CAFirstMix::incNewConnections(), CAFirstMix::incUsers(), CAInfoService::InfoLoop(), CAReplayDatabase::insert(), CADatabase::insert(), CAIPList::insertIP(), CATempIPBlockList::insertIP(), CAFirstMixChannelList::isKickoutForced(), isLoginOngoing(), CAFirstMixChannelList::isTimedOut(), CALockAble::lock(), CAAccountingInstance::loginProcessStatus(), CAFirstMixA::loop(), CAAccountingSettleThread::mainLoop(), CADatabase::nextClock(), CAReplayDatabase::nextClock(), CALibProxytest::openssl_locking_callback(), parseDOMDocument(), CAQueue::peek(), CAMuxSocket::prepareForSend(), CAMsg::printMsg(), CAControlChannelDispatcher::proccessMixPacket(), CAAccountingInstance::processJapMessageLoginHelper(), CAAccountingInstance::processThread(), CAFirstMixChannelList::pushTimeoutEntry(), CAThreadList::put(), CAMuxSocket::receive(), CAControlChannelDispatcher::registerControlChannel(), CAAccountingDBInterface::releaseConnection(), releaseDOMParser(), CAFirstMixChannelList::remove(), CASocketGroup::remove(), CASocketGroupEpoll::remove(), CAThreadList::remove(), CAMiddleMixChannelList::remove(), CASocketList::remove(), CAQueue::remove(), CAFirstMixChannelList::removeChannel(), CAFirstMixChannelToQueueList::removeChannel(), CAControlChannelDispatcher::removeControlChannel(), CALastMixBChannelList::removeFromTable(), CAIPList::removeIP(), resetLoginOngoing(), CAAccountingInstance::returnKickout(), CAAccountingInstance::returnPrepareKickout(), CASocketGroup::select(), CASocketGroupEpoll::select(), CAMuxSocket::send(), CAControlChannelDispatcher::sendMessages(), CASocketAddrINet::setAddr(), CAMuxSocket::setCrypt(), CAFirstMixChannelList::setDelayParameters(), CAFirstMixChannelList::setKickoutForced(), CAAccountingInstance::setPrepaidBytesToZero(), CAAccountingSettleThread::settle(), CAAccountingInstance::settlementTransaction(), CAThreadList::showAll(), CAConditionVariable::signal(), CAInfoService::signal(), CADatabase::simulateInsert(), CAReplayDatabase::simulateInsert(), CAInfoService::stop(), CAAccountingDBInterface::testAndResetOwner(), testAndSetLoginOwner(), CAAccountingDBInterface::testAndSetOwner(), testLoginEntryOwner(), CALockAble::unlock(), CAConditionVariable::wait(), CALockAble::waitForDestroy(), CAAccountingInstance::~CAAccountingInstance(), CADatabase::~CADatabase(), CAMiddleMixChannelList::~CAMiddleMixChannelList(), CAMuxSocket::~CAMuxSocket(), CAReplayDatabase::~CAReplayDatabase(), CATempIPBlockList::~CATempIPBlockList(), and CAThreadList::~CAThreadList().

Friends And Related Function Documentation

◆ CAConditionVariable

friend class CAConditionVariable
friend

Definition at line 63 of file CAMutex.hpp.

Member Data Documentation

◆ m_pMutex

CASemaphore* CAMutex::m_pMutex
protected

Definition at line 69 of file CAMutex.hpp.

Referenced by CAMutex(), lock(), unlock(), CAConditionVariable::wait(), and ~CAMutex().


The documentation for this class was generated from the following files: