Base class for work items that are passed through the workitem queue.
More...
#include <connect_work_item.hpp>
Base class for work items that are passed through the workitem queue.
◆ Executor
Callback function that is dispatched to work queue and is used to execute work.
◆ ExecutionContext
How to execute the work item.
Enumerator |
---|
RUN_IN_MAIN_THREAD | |
RUN_IN_WORKER_THREAD | |
◆ Priority
Priority levels for the work items.
Enumerator |
---|
LowPriority | The lowest three are subject to fairness, that is, in certain situations lower priority items are processed even if Lowest priority for work items - gets processed last.
|
NormalPriority | Normal/Default priority for work items.
|
HighPriority | Highest priority for common work items. Gets processed first.
|
SystemPriority | Highest priority for work items.
Gets processed first regardless of fairness.
|
◆ Type
Types for the work items.
Enumerator |
---|
Base | Base work item to be used for instances for ConnectWorkItem.
|
User | For user inherited work item classes, use identifier >= ID_USER.
|
◆ ConnectWorkItem()
Constructor.
- Parameters
-
type | Type of the work item. |
priority | Priority of the work item. |
executionContext | In which thread to execute the work item |
◆ ~ConnectWorkItem()
virtual kanzi::connect::ConnectWorkItem::~ConnectWorkItem |
( |
| ) |
|
|
virtual |
virtual destructor for cleanup.
◆ create()
Creates a default instance of the work item.
- Parameters
-
executionContext | Defines if the work item is to be run in main or worker thread |
- Returns
- newly allocated instance.
◆ deadlineIsEarlierThan()
bool kanzi::connect::ConnectWorkItem::deadlineIsEarlierThan |
( |
const ConnectWorkItem & | workItem | ) |
const |
Checks whether this object(s) deadline is earlier than with the "other" item.
- Parameters
-
- Returns
- true if this object triggers earlier than the other item.
◆ getExecutor()
Retrieve the executor function.
- Returns
- executor to handle the call.
◆ getPriority()
int32_t kanzi::connect::ConnectWorkItem::getPriority |
( |
| ) |
const |
retrieve the work item priority
- Returns
- numeric priority value.
◆ getTargetService()
retrieve the service this work item is traveling to.
- Returns
- service pointer.
◆ getType()
int32_t kanzi::connect::ConnectWorkItem::getType |
( |
| ) |
const |
retrieve the work item type identifier
- Returns
- numeric identifier
◆ handle()
int64_t kanzi::connect::ConnectWorkItem::handle |
( |
| ) |
const |
Returns the handle associated with the object.
Handle is available only with timed objects.
- Returns
- handle. 0 if not defined.
◆ hasExecutor()
bool kanzi::connect::ConnectWorkItem::hasExecutor |
( |
| ) |
const |
Does the object have custom executor.
- Returns
- true if executor exists.
◆ hasTimeout()
bool kanzi::connect::ConnectWorkItem::hasTimeout |
( |
| ) |
const |
determines whether object defines a timeout
- Returns
- true if timeout is defined.
◆ invokeWithExecutor()
bool kanzi::connect::ConnectWorkItem::invokeWithExecutor |
( |
| ) |
|
Dispatches the object with executor.
This function is single shot type and will clear the executor instance once complete.
- Returns
- true if executor was defined and got invoked.
◆ runInWorkerThread()
bool kanzi::connect::ConnectWorkItem::runInWorkerThread |
( |
| ) |
const |
Should this work item be run in worker thread or main thread.
- Returns
- True if worker thread
◆ setExecutor()
Setups an executor function to execute the work item.
Function can be created with std::bind.
- Parameters
-
executorFunction | function to be called when it is time to handle the functionality. |
◆ setTargetService()
setups the target service
- Parameters
-
◆ setTimeout()
void kanzi::connect::ConnectWorkItem::setTimeout |
( |
chrono::milliseconds | timeout, |
|
|
int64_t | handle ) |
Sets the timeout for the work item.
Timeout means this object will delay first specified amount of milliseconds and will then be delivered.
- Parameters
-
timeout | timeout in milliseconds to delay the delivery. |
handle | unique handle that can be used to refer to object later on. |
◆ timeoutUntilDeadline() [1/2]
chrono::milliseconds kanzi::connect::ConnectWorkItem::timeoutUntilDeadline |
( |
| ) |
const |
returns the timeout in milliseconds until this object time(s) out.
- Returns
- the timeout in milliseconds.
◆ timeoutUntilDeadline() [2/2]
chrono::milliseconds kanzi::connect::ConnectWorkItem::timeoutUntilDeadline |
( |
chrono::time_point< chrono::steady_clock > & | now | ) |
const |
returns the timeout in milliseconds until this object time(s) out.
- Parameters
-
now | current timestamp if any. |
- Returns
- timeout in milliseconds.
◆ m_executionContext
Defines whether work item should be executed in main thread or one of the workers.
◆ m_executor
Executor kanzi::connect::ConnectWorkItem::m_executor |
|
protected |
Optional executor function that get(s) invoked to handle the item instead of passing it to the services handler function.
◆ m_priority
int32_t kanzi::connect::ConnectWorkItem::m_priority |
|
protected |
◆ m_service
defines the service this work item is traveling to.
◆ m_timerInfo
optional<TimerInfo> kanzi::connect::ConnectWorkItem::m_timerInfo |
|
protected |
Optional object that defines the scheduling information.
◆ m_type
int32_t kanzi::connect::ConnectWorkItem::m_type |
|
protected |
The documentation for this class was generated from the following file:
- connect/connect_work_item.hpp