cpp-msgpack-rpc 0.2.0
An RPC library implementing MessagePack RPC.
Loading...
Searching...
No Matches
msgpack_rpc::executors::WrappingExecutor Class Referencefinal

Class to wrap existing executors. More...

Inheritance diagram for msgpack_rpc::executors::WrappingExecutor:
Collaboration diagram for msgpack_rpc::executors::WrappingExecutor:

Public Member Functions

 WrappingExecutor (std::shared_ptr< IExecutor > executor)
 Constructor.
AsioContextTypecontext (OperationType type) noexcept override
 Get the context in asio library.
bool is_running () override
 Check whether this executor is running.
std::exception_ptr last_exception () override
 Get the last exception thrown in asynchronous tasks.
void on_exception (std::function< void(std::exception_ptr)> exception_callback) override
 Register a function called when an exception is thrown in asynchronous tasks.
void start () override
 Start internal event loops to process asynchronous tasks.
void stop () override
 Stops operation.
Public Member Functions inherited from msgpack_rpc::executors::IAsyncExecutor
 IAsyncExecutor (const IAsyncExecutor &)=delete
 IAsyncExecutor (IAsyncExecutor &&)=delete
 ~IAsyncExecutor () noexcept override=default
 Destructor.
IAsyncExecutoroperator= (const IAsyncExecutor &)=delete
IAsyncExecutoroperator= (IAsyncExecutor &&)=delete
Public Member Functions inherited from msgpack_rpc::executors::IExecutor
 IExecutor (const IExecutor &)=delete
 IExecutor (IExecutor &&)=delete
virtual ~IExecutor () noexcept=default
 Destructor.
IExecutoroperator= (const IExecutor &)=delete
IExecutoroperator= (IExecutor &&)=delete

Private Attributes

std::shared_ptr< IExecutorexecutor_
 Executor.

Additional Inherited Members

Protected Member Functions inherited from msgpack_rpc::executors::IAsyncExecutor
 IAsyncExecutor () noexcept=default
 Constructor.
Protected Member Functions inherited from msgpack_rpc::executors::IExecutor
 IExecutor () noexcept=default
 Constructor.

Detailed Description

Class to wrap existing executors.

Note
Resulting wrapper won't call start, stop, run functions of the given executor.

Definition at line 39 of file wrapping_executor.cpp.

Constructor & Destructor Documentation

◆ WrappingExecutor()

msgpack_rpc::executors::WrappingExecutor::WrappingExecutor ( std::shared_ptr< IExecutor > executor)
inlineexplicit

Constructor.

Parameters
[in]executorAn existing executor.

Definition at line 46 of file wrapping_executor.cpp.

Member Function Documentation

◆ context()

AsioContextType & msgpack_rpc::executors::WrappingExecutor::context ( OperationType type)
inlineoverridevirtualnoexcept

Get the context in asio library.

Parameters
[in]typeOperation type.
Returns
Context.
Note
Implementation can return different objects for multiple function calls and different operation types.

Implements msgpack_rpc::executors::IExecutor.

Definition at line 50 of file wrapping_executor.cpp.

◆ is_running()

bool msgpack_rpc::executors::WrappingExecutor::is_running ( )
inlinenodiscardoverridevirtual

Check whether this executor is running.

Return values
trueThis executor is running.
falseThis executor is not running.

Implements msgpack_rpc::executors::IAsyncExecutor.

Definition at line 77 of file wrapping_executor.cpp.

◆ last_exception()

std::exception_ptr msgpack_rpc::executors::WrappingExecutor::last_exception ( )
inlinenodiscardoverridevirtual

Get the last exception thrown in asynchronous tasks.

Returns
Pointer of the exception.

Implements msgpack_rpc::executors::IAsyncExecutor.

Definition at line 65 of file wrapping_executor.cpp.

◆ on_exception()

void msgpack_rpc::executors::WrappingExecutor::on_exception ( std::function< void(std::exception_ptr)> exception_callback)
inlineoverridevirtual

Register a function called when an exception is thrown in asynchronous tasks.

Parameters
[in]exception_callbackFunction called when an exception is thrown in asynchronous tasks. The pointer of the exception is passed as an argument.

Implements msgpack_rpc::executors::IAsyncExecutor.

Definition at line 70 of file wrapping_executor.cpp.

◆ start()

void msgpack_rpc::executors::WrappingExecutor::start ( )
inlineoverridevirtual

Start internal event loops to process asynchronous tasks.

Note
Internal processing stops
  • when a task throws an exception, which can be retrieved from last_exception function,
  • when stop function is called.

Implements msgpack_rpc::executors::IAsyncExecutor.

Definition at line 55 of file wrapping_executor.cpp.

◆ stop()

void msgpack_rpc::executors::WrappingExecutor::stop ( )
inlineoverridevirtual

Stops operation.

Warning
This function stops internal threads. Do not call this function from callbacks called in this executor.

Implements msgpack_rpc::executors::IAsyncExecutor.

Definition at line 60 of file wrapping_executor.cpp.

Member Data Documentation

◆ executor_

std::shared_ptr<IExecutor> msgpack_rpc::executors::WrappingExecutor::executor_
private

Executor.

Definition at line 81 of file wrapping_executor.cpp.


The documentation for this class was generated from the following file: