![]() |
VSM C++ SDK
Vehicle Specific Modules SDK
|
Class for synchronizing with request execution. More...
#include <operation_waiter.h>
Public Types | |
typedef std::unique_ptr < Operation_waiter > | Ptr |
Pointer type when used as argument in callbacks. More... | |
typedef Callback_proxy< void, Ptr > | Timeout_handler |
Timeout handler prototype. More... | |
Public Member Functions | |
Operation_waiter (Request::Ptr request=nullptr) | |
Construct operation waiter. More... | |
template<class Request_type > | |
Operation_waiter (std::shared_ptr< Request_type > request) | |
Construct operation waiter from any type of request pointer. More... | |
~Operation_waiter () | |
Destructor which might wait for the request to be done. More... | |
Operation_waiter (Operation_waiter &&)=default | |
Default move constructor. More... | |
Operation_waiter (const Operation_waiter &)=delete | |
Copy constructor disabled. More... | |
Operation_waiter & | operator= (Operation_waiter &&) |
Move assignment operator. More... | |
Operation_waiter & | operator= (const Operation_waiter &)=delete |
Assignment operator is disabled. More... | |
operator bool () const | |
Test the waiter has request associated. More... | |
bool | Wait (bool process_ctx=true, std::chrono::milliseconds timeout=std::chrono::milliseconds::zero()) |
Wait for request is fully processed, i.e. More... | |
void | Timeout (std::chrono::milliseconds timeout, Timeout_handler timeout_handler=Timeout_handler(), bool cancel_operation=true, Request_completion_context::Ptr ctx=nullptr) |
Schedule timeout for the operation. More... | |
void | Cancel () |
Cancel the operation. More... | |
void | Abort () |
Abort the operation. More... | |
bool | Is_done () const |
Check if request is fully processed, i.e. More... | |
Class for synchronizing with request execution.
Instance of this class should be returned by value from asynchronous methods of request processors. Only one instance is allowed (copying is disabled).
typedef std::unique_ptr<Operation_waiter> ugcs::vsm::Operation_waiter::Ptr |
Pointer type when used as argument in callbacks.
typedef Callback_proxy<void, Ptr> ugcs::vsm::Operation_waiter::Timeout_handler |
Timeout handler prototype.
|
inline |
Construct operation waiter.
request | Associated request. No request is associated if nullptr. In such case it is dummy waiter object which behaves like its associated request is already done. |
|
inline |
Construct operation waiter from any type of request pointer.
ugcs::vsm::Operation_waiter::~Operation_waiter | ( | ) |
Destructor which might wait for the request to be done.
|
default |
Default move constructor.
|
delete |
Copy constructor disabled.
Having more than one copy of operation waiter is confusing and error prone.
void ugcs::vsm::Operation_waiter::Abort | ( | ) |
Abort the operation.
Completion handler will not be executed, unless it has been already executed or execution already started.
void ugcs::vsm::Operation_waiter::Cancel | ( | ) |
Cancel the operation.
This action behavior is defined by specific operation and processor.
|
inline |
Check if request is fully processed, i.e.
all handlers were invoked and no more actions pending.
|
inline |
Test the waiter has request associated.
Operation_waiter& ugcs::vsm::Operation_waiter::operator= | ( | Operation_waiter && | ) |
Move assignment operator.
If the waiter instance which is assigned to is not empty, it is properly destroyed.
|
delete |
Assignment operator is disabled.
Having more than one copy of operation waiter is confusing and error prone.
void ugcs::vsm::Operation_waiter::Timeout | ( | std::chrono::milliseconds | timeout, |
Timeout_handler | timeout_handler = Timeout_handler() , |
||
bool | cancel_operation = true , |
||
Request_completion_context::Ptr | ctx = nullptr |
||
) |
Schedule timeout for the operation.
After the specified time the optional callback is invoked and the operation is optionally canceled.
timeout | Timeout for the operation. |
timeout_handler | Handler which should be invoked when timeout elapses. The handler should have constant reference to Operation_waiter::Ptr as the first argument. |
cancel_operation | Cancel the operation after the timeout elapses if "true". |
ctx | Context used for handler invocation. By default the handler is invoked in request completion context, which should be present in this case. |
bool ugcs::vsm::Operation_waiter::Wait | ( | bool | process_ctx = true , |
std::chrono::milliseconds | timeout = std::chrono::milliseconds::zero() |
||
) |
Wait for request is fully processed, i.e.
all handlers were invoked and no more actions pending.
process_ctx | Process all requests in the associated completion context. This may be useful if the context is normally processed in the calling thread. |
timeout | Timeout value for waiting. Zero value indicates indefinite waiting. |