|
OpenSDN source code
|
Task is a class to describe a computational task within OpenSDN control plane applications. A task is a labelled sequence of instructions (code) and data processed by them in a single thread. OpenSDN Task wraps over tbb::task. Tasks are labelled using a pair of numbers: More...
#include <task.h>

Public Types | |
| enum | State { INIT , WAIT , RUN } |
| Task states. More... | |
| enum | TbbState { TBB_INIT , TBB_ENQUEUED , TBB_EXEC , TBB_DONE } |
| Describes states of a task according to TBB library. More... | |
Public Member Functions | |
| Task (int task_id, int task_data_id) | |
| Creates a new task with the given values of task code ID and task data ID. More... | |
| Task (int task_id) | |
| Creates a new task with the given value of task code ID and wildcard for task data ID. More... | |
| virtual | ~Task () |
| Destroys a task. More... | |
| virtual bool | Run ()=0 |
| Code to execute in a task. Returns true if task is completed. Return false to reschedule the task. More... | |
| virtual void | OnTaskCancel () |
| Called on task exit, if it is marked for cancellation. If the user wants to do any cleanup on task cancellation, then he/she can overload this function. More... | |
| State | state () const |
| Returns a state value of a task. More... | |
| int | task_code_id () const |
| Returns the code ID of this task. More... | |
| int | task_data_id () const |
| Returns the data ID of this task. More... | |
| uint64_t | seqno () const |
| Returns the sequence number of this task. More... | |
| bool | task_cancelled () const |
| Returns true if the task has been canceled. More... | |
| virtual std::string | Description () const =0 |
| Gives a description of the task. More... | |
| uint64_t | enqueue_time () const |
| Returns the time when the task was enqueued for execution. More... | |
| uint64_t | schedule_time () const |
| Returns the time when the task execution was started. More... | |
| uint32_t | execute_delay () const |
| Returns the threshold for the task execution duration. More... | |
| uint32_t | schedule_delay () const |
| Returns the time threshold for time difference between moments when the task was started and when it was enqueue. More... | |
Static Public Member Functions | |
| static Task * | Running () |
| Returns a pointer to the current task the code is executing under. More... | |
Static Public Attributes | |
| static const int | kTaskInstanceAny = -1 |
| Specifies value for wildcard (any or *) task data ID. More... | |
Private Member Functions | |
| void | seqno (uint64_t seqno) |
| Sets sequence number of the task. More... | |
| void | tbb_state (TbbState s) |
| Sets a TBB state for the task. More... | |
| void | state (State s) |
| Sets a state for this task. More... | |
| void | set_task_recycle () |
| Marks this task for recycle. More... | |
| void | set_task_complete () |
| Marks this task as completed (forbids recycling) More... | |
| void | StartTask (TaskScheduler *scheduler) |
| Starts execution of a task. More... | |
| DISALLOW_COPY_AND_ASSIGN (Task) | |
Private Attributes | |
| int | task_code_id_ |
| The code path executed by the task. More... | |
| int | task_data_id_ |
| The dataset id within a code path. More... | |
| tbb::task * | task_impl_ |
| A pointer to an Intel TBB object storing low-level information to manage the task. More... | |
| State | state_ |
| Stores a state of the task. More... | |
| TbbState | tbb_state_ |
| Stores a state of the TBB object. More... | |
| uint64_t | seqno_ |
| Stores the sequence number. More... | |
| bool | task_recycle_ |
| Determines if the task must be rescheduled (reused) after its completion. More... | |
| bool | task_cancel_ |
| Determines if the task's execution was canceled. More... | |
| uint64_t | enqueue_time_ |
| Contains the time when the task was enqueued for execution. More... | |
| uint64_t | schedule_time_ |
| Contains the time when the task was started. More... | |
| uint32_t | execute_delay_ |
| Sets threshold for the task's execution time. If the threshold is exceeded, the event is logged. More... | |
| uint32_t | schedule_delay_ |
| Sets threshold for delay between enqueueing and execution. If the threshold is exceeded, the event is logged. More... | |
| boost::intrusive::list_member_hook | waitq_hook_ |
Friends | |
| class | TaskEntry |
| Gives access to private members for TaskEntry class. More... | |
| class | TaskScheduler |
| Gives access to private members for TaskScheduler class. More... | |
| class | TaskImpl |
| Gives access to private members for TaskImpl class. More... | |
| std::ostream & | operator<< (std::ostream &out, const Task &task) |
| Provides access to private members of a task for the output stream redirection operator. More... | |
Task is a class to describe a computational task within OpenSDN control plane applications. A task is a labelled sequence of instructions (code) and data processed by them in a single thread. OpenSDN Task wraps over tbb::task. Tasks are labelled using a pair of numbers:
This labelling is used to apply execution policies determining which tasks are allowed to be executed in parallel with others and which tasks are forbidden to run in parallel. The labels are expressed as <tcid, tdid>, where tcid is a task code ID and tdid is a task data ID.
If a task with tcid has tdid equal to -1, then any number of tasks with label <tcid,-1> can run at a time. If a task has task data ID larger or equal to 0, then only one task with this given label (i.e. <tcid,tdid>) can run at a time.
When there are multiple tasks ready to run, they are scheduled in their order of enqueue.
Additionaly, parallel execution of tasks can be managed using task execution policies. Task execution policies are specified per a task with the given code ID tcid0 and arbitrary task data ID in a form of a list of task labels: <tcid0,-1> => <tcid1,tdid1>, <tcid2,tdid2>, ..., <tcidN,tdidN>.
This list specifies which tasks can't be executed in parallel with a task having specified task code ID (tcid0). Each label <tcidN, tdidN> in a policy (i.e. the list) is called task exclusion because it specifies that the task with this task code ID and task data ID cannot run in parallel with <tcid0, -1>. When tdid is equal to -1 in a task exclusion, it corresponds to wildcard (*), i.e. all possible values of the task data ID tdid.
For example, if we have a policy:
The policy states that:
Policy rules are symmetric. I.e., the previous example states also:
| enum Task::State |
| enum Task::TbbState |
| Task::Task | ( | int | task_id, |
| int | task_data_id | ||
| ) |
| Task::Task | ( | int | task_id | ) |
|
pure virtual |
Gives a description of the task.
Implemented in RequestPipeline::StageWorker, UdpServer::Reader, TcpSession::Reader, SslSession::SslReader, HttpSession::RequestHandler, cass::cql::impl::WorkerTask, ConfigEtcdClient::EtcdWatcher, ConfigAmqpClient::RabbitMQReader, PipelineWorker, Timer::TimerTask, TaskTrigger::WorkerTask, ConcurrencyScope::ScopeTask, QueueTaskRunner< QueueEntryT, QueueT >, QueueTaskRunner< QueueEntryT, WorkQueue< QueueEntryT > >, SessionStatsCollector::SessionTask, FlowStatsCollector::AgeingTask, MockGenerator::SendSessionTask, MockGenerator::SendMessageTask, RestServerGetVmCfgTask, SandeshVmVnToVmiTask, SandeshVmiToVmVnTask, SandeshVmVnPortSubscribeTask, SandeshVmiPortSubscribeTask, PktSandeshFlow, PhysicalSwitchSandeshTask, OVSDB::OvsdbSandeshTask, OvsdbClientSandesTask, OVSDB::LogicalSwitchEntry::ProcessDeleteOvsReqTask, OVSDB::LogicalSwitchTable::ProcessDeleteTableReqTask, VxLanConfigSandeshTask, ConfigPhysicalDeviceVnSandesh, MacLearningSandeshResp, FlowKState, KSyncTxQueueTask, KSyncSockUdsReadTask, KSyncSockTcpReadTask, ChannelEventProcTask, IFMapUpdateSender::SendTask, IFMapServer::IFMapVmSubscribe, IFMapServer::IFMapStaleEntriesCleaner, IFMapAgentStaleCleaner::IFMapAgentStaleCleanerWorker, DBTableWalker::Worker, DBTable::WalkWorker, DBPartition::QueueRunner, and BgpSenderPartition::Worker.
|
private |
|
inline |
|
inline |
|
inlinevirtual |
Called on task exit, if it is marked for cancellation. If the user wants to do any cleanup on task cancellation, then he/she can overload this function.
Reimplemented in Timer::TimerTask.
|
pure virtual |
Code to execute in a task. Returns true if task is completed. Return false to reschedule the task.
Implemented in RequestPipeline::StageWorker, UdpServer::Reader, TcpSession::Reader, SslSession::SslReader, HttpSession::RequestHandler, cass::cql::impl::WorkerTask, ConfigEtcdClient::EtcdWatcher, ConfigAmqpClient::RabbitMQReader, PipelineWorker, Timer::TimerTask, TaskTrigger::WorkerTask, ConcurrencyScope::ScopeTask, QueueTaskRunner< QueueEntryT, QueueT >, QueueTaskRunner< QueueEntryT, WorkQueue< QueueEntryT > >, SessionStatsCollector::SessionTask, FlowStatsCollector::AgeingTask, MockGenerator::SendSessionTask, MockGenerator::SendMessageTask, RestServerGetVmCfgTask, SandeshVmVnToVmiTask, SandeshVmiToVmVnTask, SandeshVmVnPortSubscribeTask, SandeshVmiPortSubscribeTask, PktSandeshFlowStats, PktSandeshFlow, PhysicalSwitchSandeshTask, OVSDB::OvsdbSandeshTask, OvsdbClientSandesTask, OVSDB::LogicalSwitchEntry::ProcessDeleteOvsReqTask, OVSDB::LogicalSwitchTable::ProcessDeleteTableReqTask, VxLanConfigSandeshTask, ConfigPhysicalDeviceVnSandesh, MacLearningSandeshResp, FlowKState, KSyncTxQueueTask, KSyncSockUdsReadTask, KSyncSockTcpReadTask, ChannelEventProcTask, IFMapUpdateSender::SendTask, IFMapServer::IFMapVmSubscribe, IFMapServer::IFMapStaleEntriesCleaner, IFMapAgentStaleCleaner::IFMapAgentStaleCleanerWorker, DBTableWalker::Worker, DBTable::WalkWorker, DBPartition::QueueRunner, and BgpSenderPartition::Worker.
|
static |
|
inline |
|
inline |
|
inline |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
private |
|
inline |
|
inlineprivate |
|
inline |
|
inline |
|
inline |
|
inlineprivate |
|
friend |
Provides access to private members of a task for the output stream redirection operator.
|
friend |
|
friend |
|
friend |
Gives access to private members for TaskScheduler class.
|
private |
|
private |
|
static |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |