OpenSDN source code
|
Task is a wrapper over tbb::task to support policies. More...
#include <task.h>
Public Types | |
enum | State { INIT , WAIT , RUN } |
Task states. More... | |
enum | TbbState { TBB_INIT , TBB_ENQUEUED , TBB_EXEC , TBB_DONE } |
Public Member Functions | |
Task (int task_id, int task_instance) | |
Task (int task_id) | |
virtual | ~Task () |
virtual bool | Run ()=0 |
Code to execute. 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 | GetState () const |
int | GetTaskId () const |
int | GetTaskInstance () const |
uint64_t | GetSeqno () const |
bool | task_cancelled () const |
virtual std::string | Description () const =0 |
uint64_t | enqueue_time () const |
uint64_t | schedule_time () const |
uint32_t | execute_delay () const |
uint32_t | schedule_delay () const |
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 |
Private Member Functions | |
void | SetSeqNo (uint64_t seqno) |
void | SetTbbState (TbbState s) |
void | SetState (State s) |
void | SetTaskRecycle () |
void | SetTaskComplete () |
void | StartTask (TaskScheduler *scheduler) |
Starts execution of a task. More... | |
DISALLOW_COPY_AND_ASSIGN (Task) | |
Private Attributes | |
int | task_id_ |
The code path executed by the task. More... | |
int | task_instance_ |
The dataset id within a code path. More... | |
tbb::task * | task_impl_ |
State | state_ |
TbbState | tbb_state_ |
uint64_t | seqno_ |
bool | task_recycle_ |
bool | task_cancel_ |
uint64_t | enqueue_time_ |
uint64_t | schedule_time_ |
uint32_t | execute_delay_ |
uint32_t | schedule_delay_ |
boost::intrusive::list_member_hook | waitq_hook_ |
Friends | |
class | TaskEntry |
class | TaskScheduler |
class | TaskImpl |
std::ostream & | operator<< (std::ostream &out, const Task &task) |
Task is a wrapper over tbb::task to support policies.
There are two kind of tasks,
The policies can be specified in the form of, task(tid0) => <tid1, -1> <tid2, 2> <tid3, 3> The rule implies that:
The policy rules are symmetric. That is:
If task_instance == -1, means instance is not applicable. It implies that, any number of tasks with instance -1 can run at a time
If task_instance != -1, only one task of given instnace can run at a time
When there are multiple tasks ready to run, they are scheduled in their order of enqueue
enum Task::State |
enum Task::TbbState |
|
pure virtual |
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 |
|
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. 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 |
|
private |
|
friend |
|
friend |
|
private |
|
private |