|
Ocean
|
This class implements a high performance scheduler for socket events. More...
#include <SocketScheduler.h>
Protected Types | |
| using | SocketSet = std::unordered_set< Socket * > |
| Definition of a set holding socket pointers. | |
Protected Types inherited from Ocean::Thread | |
| using | TimedJoinPair = std::pair< pthread_t, bool > |
| Definition of a pair holding a thread id and a boolean state. | |
| enum | ThreadPriority { PRIORITY_IDLE , PRIORTY_BELOW_NORMAL , PRIORTY_NORMAL , PRIORTY_ABOVE_NORMAL , PRIORTY_HIGH , PRIORTY_REALTIME } |
| Definition of different thread priority values. More... | |
Protected Member Functions | |
| SocketScheduler () | |
| Creates a new scheduler object. | |
| ~SocketScheduler () override | |
| Destructs a scheduler object. | |
| void | registerSocket (Socket &socket) |
| Register socket. | |
| void | unregisterSocket (Socket &socket) |
| Unregister socket. | |
| bool | isSocketUnregistered (Socket &socket) const |
| Checks whether a specific socket has been unregistered successfully. | |
| void | threadRun () override |
| The internal run function. | |
Protected Member Functions inherited from Ocean::Singleton< SocketScheduler > | |
| Singleton ()=default | |
| Default constructor. | |
Protected Member Functions inherited from Ocean::Thread | |
| Thread (const Thread &thread)=delete | |
| Disabled copy constructor. | |
| void | createThread () |
| Creates the thread itself. | |
| void | destroyThread () |
| Destroys the thread itself. | |
| void | stopThreadExplicitly (const unsigned int timeout=5000u) |
| Tries to stop the thread gracefully. | |
| Thread & | operator= (const Thread &thread)=delete |
| The disabled assign operator. | |
| Thread (const std::string &name=std::string()) | |
| Creates a new thread object. | |
| Thread (const unsigned int randomNumberSeedValue, const std::string &name=std::string()) | |
| Creates a new thread object. | |
| virtual | ~Thread () |
| Destructs a thread object. | |
| bool | startThread () |
| Starts the thread. | |
| void | stopThread () |
| Informs the thread to stop. | |
| bool | terminateThread () |
| Terminates the thread. | |
| bool | joinThread (const unsigned int timeout=(unsigned int)(-1)) |
| Waits until this thread has been stopped. | |
| bool | shouldThreadStop () const |
| Returns whether this thread should stop. | |
| bool | isThreadInvokedToStart () const |
| Returns whether this thread has been invoked to start immediately. | |
| bool | isThreadActive () const |
| Returns whether this thread is active. | |
Protected Attributes | |
| SocketSet | activeSockets_ |
| The active sockets of this scheduler. | |
| SocketSet | registerSockets_ |
| The set of sockets which are requested to be registered. | |
| SocketSet | unregisterSockets_ |
| The set of sockets which are requested to be unregistered. | |
| Lock | lock_ |
| The lock of this scheduler. | |
Friends | |
| class | Socket |
| class | Singleton< SocketScheduler > |
Additional Inherited Members | |
Static Public Member Functions inherited from Ocean::Singleton< SocketScheduler > | |
| static SocketScheduler & | get () |
| Returns a reference to the unique object. | |
Static Protected Member Functions inherited from Ocean::Thread | |
| static void | sleep (unsigned int ms) |
| Sleeps the calling thread for a given time. | |
| static void | giveUp () |
| Gives up the remaining thread time. | |
| static ThreadId | currentThreadId () |
| Returns the thread id of the current (calling) thread. | |
| static ThreadPriority | threadPriority () |
| Returns the priority of the current thread. | |
| static bool | setThreadPriority (const ThreadPriority priority) |
| Sets the priority of the current thread. | |
| template<typename TObject , typename TExpectedValue > | |
| static bool | waitForValue (TObject &object, const TExpectedValue &expectedValue, const double timeout=-1.0) |
| Waits until an object/variable has an expected value. | |
| template<typename TObject , typename TExpectedValue > | |
| static bool | waitForValue (TObject &object, const TExpectedValue &expectedValue, TemporaryScopedLock &temporaryScopedLock, const double timeout=-1.0) |
| Waits until an object/variable has an expected value. | |
| static int | pthread_timedjoin_np (pthread_t thread, void **retval, const struct timespec *abstime) |
| Implements a thread join function with timeout value. | |
This class implements a high performance scheduler for socket events.
|
protected |
Definition of a set holding socket pointers.
|
protected |
Creates a new scheduler object.
|
overrideprotected |
Destructs a scheduler object.
|
protected |
Checks whether a specific socket has been unregistered successfully.
| socket | The socket which is checked |
|
protected |
Register socket.
| socket | The socket to be registered |
|
overrideprotectedvirtual |
The internal run function.
Implements Ocean::Thread.
|
protected |
Unregister socket.
Beware: The unregister process is not completed immediately!
| socket | The socket to be unregistered |
|
friend |
|
protected |
The active sockets of this scheduler.
|
mutableprotected |
The lock of this scheduler.
|
protected |
The set of sockets which are requested to be registered.
|
protected |
The set of sockets which are requested to be unregistered.