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

#include <CAMutex.hpp>

Inheritance diagram for CAMutex:
[legend]

List of all members.

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

Definition at line 33 of file CAMutex.cpp.

References m_pMutex.

Referenced by CAConditionVariable::CAConditionVariable().

{
  #ifdef HAVE_PTHREAD_MUTEXES
    m_pMutex=new pthread_mutex_t;
    //m_pMutexAttributes = new pthread_mutexattr_t;
    //pthread_mutexattr_init(m_pMutexAttributes);  
    //pthread_mutexattr_settype(m_pMutexAttributes, PTHREAD_MUTEX_RECURSIVE);
    //pthread_mutexattr_settype(m_pMutexAttributes, PTHREAD_MUTEX_ERRORCHECK);
    //pthread_mutex_init(m_pMutex, m_pMutexAttributes);
    pthread_mutex_init(m_pMutex, NULL);
  #else
    m_pMutex=new CASemaphore(1);
  #endif
}
CAMutex::~CAMutex ( ) [virtual]

Definition at line 48 of file CAMutex.cpp.

References m_pMutex.

{
  #ifdef HAVE_PTHREAD_MUTEXES
  pthread_mutex_destroy(m_pMutex);
  //pthread_mutexattr_destroy(m_pMutexAttributes);          
  #endif
  delete m_pMutex;
  m_pMutex = NULL;
  
  #ifdef HAVE_PTHREAD_MUTEXES
  //delete m_pMutexAttributes;
  #endif
}

Member Function Documentation

SINT32 CAMutex::lock ( ) [inline]

Definition at line 41 of file CAMutex.hpp.

References E_SUCCESS, E_UNKNOWN, and m_pMutex.

Referenced by CAAccountingInstance::__newSettlementTransaction(), CASocket::accept(), CASocketGroupEpoll::add(), CASocketGroup::add(), CASocketList::add(), CALastMixBChannelList::add(), CAQueue::add(), CACacheLoadBalancing::add(), CAMiddleMixChannelList::add(), CAFirstMixChannelList::addChannel(), CAThreadPool::addRequest(), CASocketList::addSendMeCounter(), CAConditionVariable::broadcast(), CAMuxSocket::CAMuxSocket(), CATempIPBlockList::checkIP(), CAAccountingDBInterface::checkOwner(), CACacheLoadBalancing::clean(), CAQueue::clean(), CAAccountingInstance::cleanupTableEntry(), CATempIPBlockList::cleanupThreadMainLoop(), CASocket::close(), CAQueue::close(), CASocket::create(), CAChainTable::createEntry(), CAFirstMixChannelList::decDelayBuckets(), CAFirstMix::decNewConnections(), CAControlChannelDispatcher::decryptMessage(), CAFirstMix::decUsers(), CAControlChannelDispatcher::deleteAllControlChannels(), CAChainTable::deleteEntry(), CAThreadPool::destroy(), CAControlChannelDispatcher::encryptMessage(), CAAccountingInstance::finishLoginProcess(), fml_loopDelayBuckets(), CAFirstMixChannelList::forceKickout(), CASocketList::get(), CALastMixBChannelList::get(), CAQueue::get(), CACacheLoadBalancing::get(), CAFirstMixChannelList::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(), CAChainTable::getSize(), CAQueue::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(), CADatabase::insert(), CAReplayDatabase::insert(), CAIPList::insertIP(), CATempIPBlockList::insertIP(), iplist_loopDoLogCountries(), CAFirstMixChannelList::isKickoutForced(), isLoginOngoing(), CAFirstMixChannelList::isTimedOut(), CALockAble::lock(), CAAccountingInstance::loginProcessStatus(), CAFirstMixA::loop(), CAAccountingSettleThread::mainLoop(), CADatabase::nextClock(), CAReplayDatabase::nextClock(), CALibProxytest::openssl_locking_callback(), parseDOMDocument(), CAQueue::peek(), CAFirstMixChannelList::popTimeoutEntry(), CAMuxSocket::prepareForSend(), CAMsg::printMsg(), CAControlChannelDispatcher::proccessMixPacket(), CAAccountingInstance::processJapMessageLoginHelper(), CAAccountingInstance::processThread(), CAFirstMixChannelList::pushTimeoutEntry(), CAMuxSocket::receive(), CAControlChannelDispatcher::registerControlChannel(), CAAccountingDBInterface::releaseConnection(), releaseDOMParser(), CASocketList::remove(), CASocketGroupEpoll::remove(), CAQueue::remove(), CASocketGroup::remove(), CAMiddleMixChannelList::remove(), CAFirstMixChannelList::remove(), CAFirstMixChannelList::removeChannel(), CAControlChannelDispatcher::removeControlChannel(), CALastMixBChannelList::removeFromTable(), CAIPList::removeIP(), resetLoginOngoing(), CASocketGroupEpoll::select(), CASocketGroup::select(), CAMuxSocket::send(), CAControlChannelDispatcher::sendMessages(), CASocketAddrINet::setAddr(), CAMuxSocket::setCrypt(), CAFirstMixChannelList::setDelayParameters(), CAFirstMixChannelList::setKickoutForced(), CAAccountingInstance::setPrepaidBytesToZero(), CAAccountingSettleThread::settle(), CAAccountingInstance::settlementTransaction(), CAInfoService::signal(), CAConditionVariable::signal(), CADatabase::simulateInsert(), CAReplayDatabase::simulateInsert(), CAInfoService::stop(), CAAccountingDBInterface::testAndResetOwner(), testAndSetLoginOwner(), CAAccountingDBInterface::testAndSetOwner(), testLoginEntryOwner(), CALockAble::unlock(), CAAccountingInstance::unlockLogin(), CAConditionVariable::wait(), CALockAble::waitForDestroy(), worker_thread_main_loop(), CAAccountingInstance::~CAAccountingInstance(), CADatabase::~CADatabase(), CAMiddleMixChannelList::~CAMiddleMixChannelList(), CAMuxSocket::~CAMuxSocket(), CAReplayDatabase::~CAReplayDatabase(), CATempIPBlockList::~CATempIPBlockList(), and Hashtable::~Hashtable().

        {
          #ifdef  HAVE_PTHREAD_MUTEXES
            if(pthread_mutex_lock(m_pMutex)==0)
              return E_SUCCESS;
            return E_UNKNOWN;
          #else
            return m_pMutex->down();
          #endif
        }
SINT32 CAMutex::unlock ( ) [inline]

Definition at line 52 of file CAMutex.hpp.

References E_SUCCESS, E_UNKNOWN, and m_pMutex.

Referenced by CAAccountingInstance::__newSettlementTransaction(), CASocket::accept(), CASocketGroupEpoll::add(), CASocketGroup::add(), CASocketList::add(), CALastMixBChannelList::add(), CAQueue::add(), CACacheLoadBalancing::add(), CAMiddleMixChannelList::add(), CAFirstMixChannelList::addChannel(), CAThreadPool::addRequest(), CASocketList::addSendMeCounter(), CAConditionVariable::broadcast(), CAMuxSocket::CAMuxSocket(), CATempIPBlockList::checkIP(), CAAccountingDBInterface::checkOwner(), CACacheLoadBalancing::clean(), CAQueue::clean(), CAAccountingInstance::cleanupTableEntry(), CATempIPBlockList::cleanupThreadMainLoop(), CASocket::close(), CAQueue::close(), CASocket::create(), CAChainTable::createEntry(), CAFirstMixChannelList::decDelayBuckets(), CAFirstMix::decNewConnections(), CAControlChannelDispatcher::decryptMessage(), CAFirstMix::decUsers(), CAControlChannelDispatcher::deleteAllControlChannels(), CAChainTable::deleteEntry(), CAThreadPool::destroy(), CAControlChannelDispatcher::encryptMessage(), CAAccountingInstance::finishLoginProcess(), fml_loopDelayBuckets(), CAFirstMixChannelList::forceKickout(), CASocketList::get(), CALastMixBChannelList::get(), CAQueue::get(), CACacheLoadBalancing::get(), CAFirstMixChannelList::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(), CAChainTable::getSize(), CAQueue::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(), CADatabase::insert(), CAReplayDatabase::insert(), CAIPList::insertIP(), CATempIPBlockList::insertIP(), iplist_loopDoLogCountries(), CAFirstMixChannelList::isKickoutForced(), isLoginOngoing(), CAFirstMixChannelList::isTimedOut(), CALockAble::lock(), CAAccountingInstance::loginProcessStatus(), CAFirstMixA::loop(), CAAccountingSettleThread::mainLoop(), CADatabase::nextClock(), CAReplayDatabase::nextClock(), CALibProxytest::openssl_locking_callback(), parseDOMDocument(), CAQueue::peek(), CAFirstMixChannelList::popTimeoutEntry(), CAMuxSocket::prepareForSend(), CAMsg::printMsg(), CAControlChannelDispatcher::proccessMixPacket(), CAAccountingInstance::processJapMessageLoginHelper(), CAAccountingInstance::processThread(), CAFirstMixChannelList::pushTimeoutEntry(), CAMuxSocket::receive(), CAControlChannelDispatcher::registerControlChannel(), CAAccountingDBInterface::releaseConnection(), releaseDOMParser(), CASocketList::remove(), CASocketGroupEpoll::remove(), CAQueue::remove(), CASocketGroup::remove(), CAMiddleMixChannelList::remove(), CAFirstMixChannelList::remove(), CAFirstMixChannelList::removeChannel(), CAControlChannelDispatcher::removeControlChannel(), CALastMixBChannelList::removeFromTable(), CAIPList::removeIP(), resetLoginOngoing(), CAAccountingInstance::returnKickout(), CAAccountingInstance::returnPrepareKickout(), CASocketGroupEpoll::select(), CASocketGroup::select(), CAMuxSocket::send(), CAControlChannelDispatcher::sendMessages(), CASocketAddrINet::setAddr(), CAMuxSocket::setCrypt(), CAFirstMixChannelList::setDelayParameters(), CAFirstMixChannelList::setKickoutForced(), CAAccountingInstance::setPrepaidBytesToZero(), CAAccountingSettleThread::settle(), CAAccountingInstance::settlementTransaction(), CAInfoService::signal(), CAConditionVariable::signal(), CADatabase::simulateInsert(), CAReplayDatabase::simulateInsert(), CAInfoService::stop(), CAAccountingDBInterface::testAndResetOwner(), testAndSetLoginOwner(), CAAccountingDBInterface::testAndSetOwner(), testLoginEntryOwner(), CALockAble::unlock(), CAAccountingInstance::unlockLogin(), CAConditionVariable::wait(), CALockAble::waitForDestroy(), worker_thread_main_loop(), CAAccountingInstance::~CAAccountingInstance(), CADatabase::~CADatabase(), CAMiddleMixChannelList::~CAMiddleMixChannelList(), CAMuxSocket::~CAMuxSocket(), CAReplayDatabase::~CAReplayDatabase(), CATempIPBlockList::~CATempIPBlockList(), and Hashtable::~Hashtable().

        {
          #ifdef HAVE_PTHREAD_MUTEXES
            if(pthread_mutex_unlock(m_pMutex)==0)
              return E_SUCCESS;
            return E_UNKNOWN;
          #else
            return m_pMutex->up();
          #endif
        }

Friends And Related Function Documentation

friend class CAConditionVariable [friend]

Definition at line 63 of file CAMutex.hpp.


Member Data Documentation

CASemaphore* CAMutex::m_pMutex [protected]

Reimplemented in CAConditionVariable.

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: