HTTP Virtual File specific work item. More...
#include <virtualfileworkitem.hpp>
Public Types | |
enum | { WORK_ITEM_TYPE = ConnectWorkItem::User } |
![]() | |
enum class | ExecutionContext { RUN_IN_MAIN_THREAD , RUN_IN_WORKER_THREAD } |
How to execute the work item. More... | |
typedef function< void(void)> | Executor |
Callback function that is dispatched to work queue and is used to execute work. | |
enum | Priority { LowPriority = 1 , NormalPriority = 10 , HighPriority = 20 , SystemPriority = 30 } |
Priority levels for the work items. More... | |
enum | Type { Base , User = 1000 } |
Types for the work items. More... | |
Public Member Functions | |
int | getHandle () const |
Retrieve handle. | |
const string & | getMime () const |
Retrieve MIME type. | |
const string | getResultAsData () const |
Retrieve result file content. | |
const string | getResultAsFile () const |
Retrieves the filepath. | |
const string | getResultAsURI () const |
Retrieves the uri. | |
shared_ptr< VirtualfileServiceConcept::Session > | getSession () const |
Retrieve session. | |
const string & | getUri () const |
Retrieve the uri where from the content is to be retrieved. | |
bool | hasResultAsData () const |
Determine whether result file content is set. | |
bool | hasResultAsFile () const |
Determine whether filepath is defined. | |
bool | hasResultAsUri () const |
Determine whether uri is defined. | |
void | notifyComplete () |
Completes the pending object. | |
void | setHandle (int handle) |
Store the handle. | |
void | setMime (const string &mime) |
Store the MIME type of the returned object. | |
void | setResultAsData (const string &fileContent) |
Sets the result file content. | |
void | setResultAsData (const unsigned char *bytes, size_t length) |
Sets result file content as a binary (can also be text, obviously) | |
void | setResultAsFile (const string &filename) |
Sets result as a file. | |
void | setResultAsURI (const string &uri) |
Sets uri. | |
void | setSession (shared_ptr< VirtualfileServiceConcept::Session > session) |
Store session. | |
VirtualFileWorkItem (int32_t priority, string uri) | |
Constructor. | |
bool | waitUntilComplete (int ms) |
Waits for this object to be completed. | |
virtual | ~VirtualFileWorkItem () |
C++ destructor. | |
![]() | |
ConnectWorkItem (int32_t type=Base, int32_t priority=NormalPriority, ExecutionContext executionContext=ExecutionContext::RUN_IN_MAIN_THREAD) | |
Constructor. | |
bool | deadlineIsEarlierThan (const ConnectWorkItem &workItem) const |
Checks whether this object(s) deadline is earlier than with the "other" item. | |
ConnectWorkItem::Executor | getExecutor () const |
Retrieve the executor function. | |
int32_t | getPriority () const |
retrieve the work item priority | |
AbstractServiceSharedPtr | getTargetService () |
retrieve the service this work item is traveling to. | |
int32_t | getType () const |
retrieve the work item type identifier | |
int64_t | handle () const |
Returns the handle associated with the object. | |
bool | hasExecutor () const |
Does the object have custom executor. | |
bool | hasTimeout () const |
determines whether object defines a timeout | |
bool | invokeWithExecutor () |
Dispatches the object with executor. | |
bool | runInWorkerThread () const |
Should this work item be run in worker thread or main thread. | |
void | setExecutor (ConnectWorkItem::Executor executorFunction) |
Setups an executor function to execute the work item. | |
void | setTargetService (AbstractServiceSharedPtr service) |
setups the target service | |
void | setTimeout (chrono::milliseconds timeout, int64_t handle) |
Sets the timeout for the work item. | |
chrono::milliseconds | timeoutUntilDeadline () const |
returns the timeout in milliseconds until this object time(s) out. | |
chrono::milliseconds | timeoutUntilDeadline (chrono::time_point< chrono::steady_clock > &now) const |
returns the timeout in milliseconds until this object time(s) out. | |
virtual | ~ConnectWorkItem () |
virtual destructor for cleanup. | |
Protected Attributes | |
int | m_handle |
string | m_mime |
optional< string > | m_resultContent |
optional< string > | m_resultFilePath |
optional< string > | m_resultRedirectUri |
shared_ptr< VirtualfileServiceConcept::Session > | m_session |
string | m_uri |
The URI to retrieve. | |
Wait | m_waiter |
Wait object used with multiple threads. | |
![]() | |
ExecutionContext | m_executionContext |
Defines whether work item should be executed in main thread or one of the workers. | |
Executor | m_executor |
Optional executor function that get(s) invoked to handle the item instead of passing it to the services handler function. | |
int32_t | m_priority |
Priority value. | |
AbstractServiceWeakPtr | m_service |
defines the service this work item is traveling to. | |
optional< TimerInfo > | m_timerInfo |
Optional object that defines the scheduling information. | |
int32_t | m_type |
Type identifier. | |
Additional Inherited Members | |
![]() | |
static ConnectWorkItemSharedPtr | create (ExecutionContext executionContext=ExecutionContext::RUN_IN_MAIN_THREAD) |
Creates a default instance of the work item. | |
HTTP Virtual File specific work item.
Encapsulates effectively one request where incoming data is the URI and outgoing data is the result in three possible forms (data-as-is, full-path-to-file, redirect-to-url).
|
inlinevirtual |
C++ destructor.
kanzi::connect::VirtualFileWorkItem::VirtualFileWorkItem | ( | int32_t | priority, |
string | uri ) |
Constructor.
priority | Priority of the work item. |
int kanzi::connect::VirtualFileWorkItem::getHandle | ( | ) | const |
Retrieve handle.
const string & kanzi::connect::VirtualFileWorkItem::getMime | ( | ) | const |
Retrieve MIME type.
const string kanzi::connect::VirtualFileWorkItem::getResultAsData | ( | ) | const |
Retrieve result file content.
const string kanzi::connect::VirtualFileWorkItem::getResultAsFile | ( | ) | const |
Retrieves the filepath.
const string kanzi::connect::VirtualFileWorkItem::getResultAsURI | ( | ) | const |
Retrieves the uri.
shared_ptr< VirtualfileServiceConcept::Session > kanzi::connect::VirtualFileWorkItem::getSession | ( | ) | const |
Retrieve session.
const string & kanzi::connect::VirtualFileWorkItem::getUri | ( | ) | const |
Retrieve the uri where from the content is to be retrieved.
bool kanzi::connect::VirtualFileWorkItem::hasResultAsData | ( | ) | const |
Determine whether result file content is set.
bool kanzi::connect::VirtualFileWorkItem::hasResultAsFile | ( | ) | const |
Determine whether filepath is defined.
bool kanzi::connect::VirtualFileWorkItem::hasResultAsUri | ( | ) | const |
Determine whether uri is defined.
void kanzi::connect::VirtualFileWorkItem::notifyComplete | ( | ) |
Completes the pending object.
void kanzi::connect::VirtualFileWorkItem::setHandle | ( | int | handle | ) |
Store the handle.
handle | handle to store. |
void kanzi::connect::VirtualFileWorkItem::setMime | ( | const string & | mime | ) |
Store the MIME type of the returned object.
mime | The MIME type. |
void kanzi::connect::VirtualFileWorkItem::setResultAsData | ( | const string & | fileContent | ) |
Sets the result file content.
fileContent | buffer containing the dat.a |
void kanzi::connect::VirtualFileWorkItem::setResultAsData | ( | const unsigned char * | bytes, |
size_t | length ) |
Sets result file content as a binary (can also be text, obviously)
bytes | raw buffer |
length | size of data in buffer |
void kanzi::connect::VirtualFileWorkItem::setResultAsFile | ( | const string & | filename | ) |
Sets result as a file.
filename | full path to file. |
void kanzi::connect::VirtualFileWorkItem::setResultAsURI | ( | const string & | uri | ) |
Sets uri.
uri | the uri to set. |
void kanzi::connect::VirtualFileWorkItem::setSession | ( | shared_ptr< VirtualfileServiceConcept::Session > | session | ) |
Store session.
session | The session to store. |
bool kanzi::connect::VirtualFileWorkItem::waitUntilComplete | ( | int | ms | ) |
Waits for this object to be completed.
ms | how long to wait max. |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
The URI to retrieve.
|
protected |
Wait object used with multiple threads.