The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

Mutex Class Reference

The Mutex class represents a mutex, which can be used to keep threads properly synchronised. More...

#include <threadengine.h>

Inheritance diagram for Mutex:

Inheritance graph
[legend]
Collaboration diagram for Mutex:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Mutex (InspIRCd *Instance)
 Constructor.
void Lock ()
 Enter/enable the mutex lock.
void Unlock ()
 Leave/disable the mutex lock.
 ~Mutex ()
 Destructor.

Protected Member Functions

virtual void Enable (bool enable)=0
 Enable or disable the Mutex.

Protected Attributes

InspIRCdServerInstance
 Creator object.

Detailed Description

The Mutex class represents a mutex, which can be used to keep threads properly synchronised.

Use mutexes sparingly, as they are a good source of thread deadlocks etc, and should be avoided except where absolutely neccessary. Note that the internal behaviour of the mutex varies from OS to OS depending on the thread engine, for example in windows a Mutex in InspIRCd uses critical sections, as they are faster and simpler to manage.

Definition at line 115 of file threadengine.h.


Constructor & Destructor Documentation

Mutex::Mutex InspIRCd Instance  ) 
 

Constructor.

Parameters:
Instance Creator object

Definition at line 31 of file threadengine.cpp.

Mutex::~Mutex  )  [inline]
 

Destructor.

Definition at line 149 of file threadengine.h.


Member Function Documentation

virtual void Mutex::Enable bool  enable  )  [protected, pure virtual]
 

Enable or disable the Mutex.

This method has somewhat confusing wording (e.g. the function name and parameters) so it is protected in preference of the Lock() and Unlock() methods which are user- accessible.

Parameters:
enable True to enable the mutex (enter it) and false to disable the mutex (leave it).

void Mutex::Lock  )  [inline]
 

Enter/enable the mutex lock.

Definition at line 141 of file threadengine.h.

Referenced by ModuleMsSQL::AddConn(), ConnectDatabases(), SQLConnection::DoLeadingQuery(), SQLConn::HandleError(), SQLConn::HandleMessage(), LoadDatabases(), ModuleMsSQL::ModuleMsSQL(), ModuleSQL::ModuleSQL(), Notifier::OnDataReady(), ModuleMsSQL::OnRehash(), ModuleSQL::OnRequest(), ModuleMsSQL::OnRequest(), SQLConn::Query(), DispatcherThread::Run(), QueryThread::Run(), SQLConn::SendResults(), and SQLConn::SQLConn().

void Mutex::Unlock  )  [inline]
 

Leave/disable the mutex lock.

Definition at line 145 of file threadengine.h.

Referenced by ModuleMsSQL::AddConn(), ConnectDatabases(), SQLConnection::DoLeadingQuery(), SQLConn::HandleError(), SQLConn::HandleMessage(), LoadDatabases(), ModuleMsSQL::ModuleMsSQL(), ModuleSQL::ModuleSQL(), Notifier::OnDataReady(), ModuleMsSQL::OnRehash(), ModuleSQL::OnRequest(), ModuleMsSQL::OnRequest(), SQLConn::Query(), DispatcherThread::Run(), QueryThread::Run(), SQLConn::SendResults(), and SQLConn::SQLConn().


Member Data Documentation

InspIRCd* Mutex::ServerInstance [protected]
 

Creator object.

Definition at line 121 of file threadengine.h.


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