This class implements a queue for tasks.
More...
#include <TaskQueue.h>
|
typedef Caller< void > | Task |
| Definition of a task as caller function.
|
|
|
void | pushTask (const Task &task) |
| Adds a new tasks to the queue which will be invoked after all previous task have been invoked.
|
|
size_t | pendingTasks () |
| Returns the number of tasks currently in the queue (not counting an currently invoked task).
|
|
void | clear () |
| Removes all pending tasks from this queue.
|
|
|
| TaskQueue () |
| Creates a new task queue object.
|
|
| ~TaskQueue () |
| Destructs a task queue object.
|
|
virtual void | threadRun () |
| The thread run function.
|
|
| Singleton ()=default |
| Default constructor.
|
|
| 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.
|
|
|
static TaskQueue & | get () |
| Returns a reference to the unique object.
|
|
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 queue for tasks.
The queue is based on a single thread so that all tasks will be processes sequential in a normal FIFO queue order.
In contrast to the Scheduler the TaskQueue invokes a function only once.
- See also
- Scheduler, ThreadPool.
◆ Task
Definition of a task as caller function.
◆ Tasks
Definition of a queue holding tasks.
◆ TaskQueue()
Ocean::TaskQueue::TaskQueue |
( |
| ) |
|
|
protected |
Creates a new task queue object.
◆ ~TaskQueue()
Ocean::TaskQueue::~TaskQueue |
( |
| ) |
|
|
protected |
Destructs a task queue object.
◆ clear()
void Ocean::TaskQueue::clear |
( |
| ) |
|
Removes all pending tasks from this queue.
A currently invoked task will not be stopped.
◆ pendingTasks()
size_t Ocean::TaskQueue::pendingTasks |
( |
| ) |
|
Returns the number of tasks currently in the queue (not counting an currently invoked task).
- Returns
- The number of pending tasks.
◆ pushTask()
void Ocean::TaskQueue::pushTask |
( |
const Task & |
task | ) |
|
Adds a new tasks to the queue which will be invoked after all previous task have been invoked.
- Parameters
-
◆ threadRun()
virtual void Ocean::TaskQueue::threadRun |
( |
| ) |
|
|
protectedvirtual |
◆ Singleton< TaskQueue >
◆ queueHadTask
bool Ocean::TaskQueue::queueHadTask |
|
protected |
True, if at least one task has been added to this queue before.
◆ queueLock
Lock Ocean::TaskQueue::queueLock |
|
protected |
◆ queueTasks
Tasks Ocean::TaskQueue::queueTasks |
|
protected |
The documentation for this class was generated from the following file: