|
|||
|
|||
|
#include <threadengine.h>
Inheritance diagram for ThreadEngine:


Public Member Functions | |
| ThreadEngine (InspIRCd *Instance) | |
| Constructor. | |
| virtual | ~ThreadEngine () |
| Destructor. | |
| void | Lock () |
| Lock the system wide mutex. | |
| void | Unlock () |
| Unlock the system wide mutex. | |
| virtual void | Run ()=0 |
| Run the newly created thread. | |
| virtual void | Create (Thread *thread_to_init)=0 |
| Create a new thread. | |
| virtual void | FreeThread (Thread *thread)=0 |
| This is called by the default destructor of the Thread class to ensure that the thread engine which created the thread is responsible for destroying it. | |
| virtual const std::string | GetName () |
| Returns the thread engine's name for display purposes. | |
Protected Member Functions | |
| virtual bool | Mutex (bool enable)=0 |
| Enable or disable system-wide mutex for threading. | |
Protected Attributes | |
| InspIRCd * | ServerInstance |
| Creator instance. | |
| Thread * | NewThread |
| New Thread being created. | |
It does this by creating operating system level threads which are then associated with the class transparently. This allows Thread classes to be derived without needing to know how the OS implements threads. You should ensure that any sections of code that use threads are threadsafe and do not interact with any other parts of the code which are NOT known threadsafe! If you really MUST access non-threadsafe code from a Thread, use the Mutex class to wrap access to the code carefully.
Definition at line 36 of file threadengine.h.
|
|
Constructor.
Definition at line 23 of file threadengine.cpp. |
|
|
Destructor.
Definition at line 27 of file threadengine.cpp. |
|
|
Create a new thread. This takes an already allocated Thread* pointer and initializes it to use this threading engine. On failure, this function may throw a CoreException.
Referenced by TestSuite::DoThreadTests(), InspIRCd::InspIRCd(), ModuleMsSQL::ModuleMsSQL(), and ModuleSQL::ModuleSQL(). |
|
|
This is called by the default destructor of the Thread class to ensure that the thread engine which created the thread is responsible for destroying it.
|
|
|
Returns the thread engine's name for display purposes.
Definition at line 101 of file threadengine.h. Referenced by TestSuite::DoThreadTests(). |
|
|
Lock the system wide mutex. See the documentation for ThreadEngine::Mutex(). Definition at line 72 of file threadengine.h. Referenced by ServerConfig::Read(), and ConfigReaderThread::Run(). |
|
|
Enable or disable system-wide mutex for threading. Remember that if you toggle the mutex you MUST UNSET IT LATER otherwise the program will DEADLOCK! It is recommended that you AVOID USE OF THIS METHOD and use your own Mutex class, this function is mainly reserved for use by the core and by the Thread engine itself.
|
|
|
Run the newly created thread.
|
|
|
Unlock the system wide mutex. See the documentation for ThreadEngine::Mutex() Definition at line 77 of file threadengine.h. Referenced by ServerConfig::Read(), and ConfigReaderThread::Run(). |
|
|
New Thread being created.
Definition at line 46 of file threadengine.h. |
|
|
Creator instance.
Definition at line 42 of file threadengine.h. |