|
Ocean
|
This class wraps the ThreadPool into a singleton for global usage. More...
#include <ThreadPool.h>
Protected Member Functions | |
| ThreadPoolSingleton () | |
| Protected default constructor. | |
Protected Member Functions inherited from Ocean::Singleton< ThreadPoolSingleton > | |
| Singleton ()=default | |
| Default constructor. | |
Protected Member Functions inherited from Ocean::ThreadPool | |
| void | threadRun () override |
| Thread run function. | |
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. | |
Friends | |
| class | Singleton< ThreadPoolSingleton > |
Additional Inherited Members | |
Public Types inherited from Ocean::ThreadPool | |
| using | Function = std::function< void()> |
| Definition of a caller function without return parameter. | |
Public Member Functions inherited from Ocean::ThreadPool | |
| ThreadPool ()=default | |
| Creates a new thread pool object. | |
| ~ThreadPool () override | |
| Destructs a thread pool. | |
| size_t | capacity () const |
| Returns the maximal number of thread objects allowed inside this pool. | |
| size_t | size () const |
| Returns the number of currently busy/active threads in this pool. | |
| bool | setCapacity (const size_t capacity) |
| Defines the maximal number of thread objects existing concurrently. | |
| bool | invoke (Function &&function) |
| Invokes a function on one of the free threads of this pool. | |
| size_t | pending () const |
| Returns the number of pending functions. | |
| bool | isEmpty () const |
| Returns whether the ThreadPool has completed all jobs that have been submitted. | |
Static Public Member Functions inherited from Ocean::Singleton< ThreadPoolSingleton > | |
| static ThreadPoolSingleton & | get () |
| Returns a reference to the unique object. | |
Protected Types inherited from Ocean::ThreadPool | |
| using | UniquePoolThread = std::unique_ptr< PoolThread > |
| Definition of a unique pointer holding a pool thread. | |
| using | PoolThreads = std::vector< UniquePoolThread > |
| Definition of a vector holding pool threads. | |
| using | FunctionQueue = std::queue< Function > |
| Definition of a queue holding functions. | |
Protected Types inherited from Ocean::Thread | |
| typedef std::pair< pthread_t, bool > | TimedJoinPair |
| 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... | |
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. | |
Protected Attributes inherited from Ocean::ThreadPool | |
| PoolThreads | busyPoolThreads_ |
| The busy pool threads. | |
| PoolThreads | idlePoolThreads_ |
| The idle pool threads. | |
| FunctionQueue | pendingFunctions_ |
| The pending functions. | |
| size_t | capacity_ = 2 |
| Maximal pool capacity, with range [1, infinity) | |
| size_t | poolThreadIdCounter_ = 0 |
| The counter for pool thread ids. | |
| Lock | lock_ |
| Pool lock. | |
This class wraps the ThreadPool into a singleton for global usage.
Use the standard ThreadPool in case a singleton is not sufficient.
|
protected |
Protected default constructor.
|
friend |