|
| static task_id_t | addTask (time_t delaySec, task_t task) |
| | Add task to queue, ctx that passed to task equals to NULL. More...
|
| |
| static task_id_t | addTask (void *ctx, time_t delaySec, task_t task) |
| | Add task to queue, ctx passed to task by pointer without copy. More...
|
| |
| static task_id_t | addTaskWithCopy (const void *ctx, size_t size, time_t delaySec, task_t task) |
| | Add task to queue, ctx passed to task by pointer with copy, allocated memory will be relesed after deleting task from queue. More...
|
| |
| static size_t | getTaskCnt () |
| | Returns count of tasks in the queue. Tasks count does not immediately updated after request to remove task. More...
|
| |
| static bool | isTaskExist (task_id_t id) |
| | Returns true if task exists in the queue. More...
|
| |
| static bool | isTaskIdle (task_id_t id) |
| | Returns true if state corresponds to function. More...
|
| |
| static bool | isTaskExecuting (task_id_t id) |
| |
| static bool | isTaskShouldBeDeleted (task_id_t id) |
| |
| static void | requestToRemoveTask (task_id_t id) |
| | This function does not immediately delete the task, it only marks it as one that should be deleted at the first opportunity, namely when executingEachTask() is called. At the same time, calling requestToRemoveTask() guarantees that the task will no longer be executed. There is only one exception if the requestToRemoveTask() call refers to a task that is being executed right at this moment, then the deletion will take place only after the execution is completed, so the user must guarantee the validity of the context and the parameters passed through the capture before the execution of this task is completed. If after exiting this method the task is not in the EXECUTING state, the user can be sure that the task is not executed and will not be executed again, and the context will no longer be used. If, after exiting, the task is in EXECUTING, the user can wait until it is completed by polling the isTaskExecuting() method. More...
|
| |
| static void | requestToRemoveEachTask () |
| | This function does not immediately delete all tasks, it only marks them as one that should be deleted at the first opportunity, namely when executingEachTask() is called. At the same time, calling requestToRemoveEachTask() guarantees that the tasks will no longer be executed. There is only one exception if the requestToRemoveEachTask() calls during task execution right at this moment, then the deletion will take place only after the execution is completed, so the user must guarantee the validity of the context and the parameters passed through the capture before the execution of this task is completed. If after exiting this method the task is not in the EXECUTING state, the user can be sure that the task is not executed and will not be executed again, and the context will no longer be used. If, after exiting, the task is in EXECUTING, the user can wait until it is completed by polling the isTaskExecuting() method. More...
|
| |
| static void | hardReset () |
| | Blocks task handling, calls of other methods, and deletes all tasks from the queue, after that returns control over the queue. More...
|
| |
| static time_t | handleEachTask (WppClient &client) |
| | Execute each task in the queue and delete it from queue if task returns false or task state is SHOULD_BE_DELETED. This method is called by the WppClient in its loop() method. But it can be also called by the user if he wants to process immediately. More...
|
| |
Represents a task queue.
The queue of tasks does not guarantee timely calling of a task with a fixed delay, all tasks in the queue are processed sequentially, it is only guaranteed that the task will be called after the specified delay. The queue should not be used for critical tasks. When a task is created via addTask(), the party that creates the task must guarantee the validity of the ctx_t ctx during the entire existence of the task. Tasks may be deleted not immediately, but with the next call to handleEachTask(), but it is guaranteed that the deleted task will not be executed. It is forbidden to use any delays in the task, because all the tasks are executed sequentially in the same thread, this will cause an execution delay for other tasks. WppTaskQueue should be used only for tasks that require the WppClient context.
The implementation is completely thread-safe and allows calling its methods from tasks.
- Note
- The WppTaskQueue class is a singleton.
Definition at line 50 of file WppTaskQueue.h.
| void wpp::WppTaskQueue::requestToRemoveEachTask |
( |
| ) |
|
|
static |
This function does not immediately delete all tasks, it only marks them as one that should be deleted at the first opportunity, namely when executingEachTask() is called. At the same time, calling requestToRemoveEachTask() guarantees that the tasks will no longer be executed. There is only one exception if the requestToRemoveEachTask() calls during task execution right at this moment, then the deletion will take place only after the execution is completed, so the user must guarantee the validity of the context and the parameters passed through the capture before the execution of this task is completed. If after exiting this method the task is not in the EXECUTING state, the user can be sure that the task is not executed and will not be executed again, and the context will no longer be used. If, after exiting, the task is in EXECUTING, the user can wait until it is completed by polling the isTaskExecuting() method.
Definition at line 150 of file WppTaskQueue.cpp.
| void wpp::WppTaskQueue::requestToRemoveTask |
( |
task_id_t |
id | ) |
|
|
static |
This function does not immediately delete the task, it only marks it as one that should be deleted at the first opportunity, namely when executingEachTask() is called. At the same time, calling requestToRemoveTask() guarantees that the task will no longer be executed. There is only one exception if the requestToRemoveTask() call refers to a task that is being executed right at this moment, then the deletion will take place only after the execution is completed, so the user must guarantee the validity of the context and the parameters passed through the capture before the execution of this task is completed. If after exiting this method the task is not in the EXECUTING state, the user can be sure that the task is not executed and will not be executed again, and the context will no longer be used. If, after exiting, the task is in EXECUTING, the user can wait until it is completed by polling the isTaskExecuting() method.
Definition at line 137 of file WppTaskQueue.cpp.