|
cpp-msgpack-rpc 0.2.0
An RPC library implementing MessagePack RPC.
|
Class of general-purpose executors. More...
Classes | |
| struct | ContextThreadPair |
| Pair of context and its thread. More... | |
Public Member Functions | |
| GeneralExecutor (const GeneralExecutor &)=delete | |
| GeneralExecutor (GeneralExecutor &&)=delete | |
| GeneralExecutor (std::shared_ptr< logging::Logger > logger, const config::ExecutorConfig &config) | |
| Constructor. | |
| ~GeneralExecutor () override | |
| Destructor. | |
| AsioContextType & | context (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. | |
| GeneralExecutor & | operator= (const GeneralExecutor &)=delete |
| GeneralExecutor & | operator= (GeneralExecutor &&)=delete |
| 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. | |
| IAsyncExecutor & | operator= (const IAsyncExecutor &)=delete |
| IAsyncExecutor & | operator= (IAsyncExecutor &&)=delete |
| Public Member Functions inherited from msgpack_rpc::executors::IExecutor | |
| IExecutor (const IExecutor &)=delete | |
| IExecutor (IExecutor &&)=delete | |
| virtual | ~IExecutor () noexcept=default |
| Destructor. | |
| IExecutor & | operator= (const IExecutor &)=delete |
| IExecutor & | operator= (IExecutor &&)=delete |
Private Member Functions | |
| void | async_stop_threads_gently () |
| Notify threads to stop operations gently. | |
| void | interrupt_threads () |
| Notify threads to stop operations. | |
| void | run_in_thread (AsioContextType &context) |
| Run operations in a thread. | |
| void | start_threads () |
| Start threads. | |
| void | stop_threads () |
| Stop threads. | |
Static Private Member Functions | |
| static std::string | create_thread_id_string () |
| Create a string of the current thread ID. | |
| static std::size_t | get_context_index (std::atomic< std::size_t > &index, std::size_t size) |
| Get the index of context to use. | |
Private Attributes | |
| std::atomic< std::size_t > | callback_context_index_ {0} |
| Index of context to use for callbacks. | |
| std::vector< ContextThreadPair > | callbacks_context_thread_pairs_ |
| List of pairs of context and its thread for callbacks. | |
| std::vector< std::function< void(std::exception_ptr)> > | exception_callbacks_ {} |
| Functions called when an exception is thrown. | |
| std::mutex | exception_callbacks_mutex_ {} |
| Mutex of exception_callbacks_. | |
| std::exception_ptr | exception_in_thread_ {} |
| Exception thrown in threads. | |
| std::mutex | exception_in_thread_mutex_ {} |
| Mutex of exception_in_thread_. | |
| std::atomic< bool > | is_started_ {false} |
| Whether this executor has been started. | |
| std::atomic< bool > | is_stopped_ {false} |
| Whether this executor has been stopped. | |
| std::shared_ptr< logging::Logger > | logger_ |
| Logger. | |
| std::atomic< std::size_t > | transport_context_index_ {0} |
| Index of context to use for transport. | |
| std::vector< ContextThreadPair > | transport_context_thread_pairs_ |
| List of pairs of context and its thread for transport. | |
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. | |
Class of general-purpose executors.
Definition at line 47 of file general_executor.cpp.
|
inline |
Constructor.
| [in] | logger | Logger. |
| [in] | config | Configuration. |
Definition at line 55 of file general_executor.cpp.
|
inlineoverride |
Destructor.
Definition at line 69 of file general_executor.cpp.
|
inlineprivate |
Notify threads to stop operations gently.
Definition at line 195 of file general_executor.cpp.
|
inlineoverridevirtualnoexcept |
Get the context in asio library.
| [in] | type | Operation type. |
Implements msgpack_rpc::executors::IExecutor.
Definition at line 99 of file general_executor.cpp.
|
inlinestaticprivate |
Create a string of the current thread ID.
Definition at line 239 of file general_executor.cpp.
|
inlinestaticprivate |
Get the index of context to use.
| [in] | index | Atomic variable of the index of context. |
| [in] | size | Number of context. |
Definition at line 252 of file general_executor.cpp.
|
inlineprivate |
Notify threads to stop operations.
Definition at line 183 of file general_executor.cpp.
|
inlinenodiscardoverridevirtual |
Check whether this executor is running.
| true | This executor is running. |
| false | This executor is not running. |
Implements msgpack_rpc::executors::IAsyncExecutor.
Definition at line 130 of file general_executor.cpp.
|
inlinenodiscardoverridevirtual |
Get the last exception thrown in asynchronous tasks.
Implements msgpack_rpc::executors::IAsyncExecutor.
Definition at line 117 of file general_executor.cpp.
|
inlineoverridevirtual |
Register a function called when an exception is thrown in asynchronous tasks.
| [in] | exception_callback | Function 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 123 of file general_executor.cpp.
|
inlineprivate |
Run operations in a thread.
| [in] | context | Context for this thread. |
Definition at line 209 of file general_executor.cpp.
|
inlineoverridevirtual |
Start internal event loops to process asynchronous tasks.
Implements msgpack_rpc::executors::IAsyncExecutor.
Definition at line 72 of file general_executor.cpp.
|
inlineprivate |
Start threads.
Definition at line 143 of file general_executor.cpp.
|
inlineoverridevirtual |
Stops operation.
Implements msgpack_rpc::executors::IAsyncExecutor.
Definition at line 83 of file general_executor.cpp.
|
inlineprivate |
Stop threads.
Definition at line 166 of file general_executor.cpp.
|
private |
Index of context to use for callbacks.
Definition at line 285 of file general_executor.cpp.
|
private |
List of pairs of context and its thread for callbacks.
Definition at line 279 of file general_executor.cpp.
|
private |
Functions called when an exception is thrown.
Definition at line 300 of file general_executor.cpp.
|
private |
Mutex of exception_callbacks_.
Definition at line 303 of file general_executor.cpp.
|
private |
Exception thrown in threads.
Definition at line 294 of file general_executor.cpp.
|
private |
Mutex of exception_in_thread_.
Definition at line 297 of file general_executor.cpp.
|
private |
Whether this executor has been started.
Definition at line 288 of file general_executor.cpp.
|
private |
Whether this executor has been stopped.
Definition at line 291 of file general_executor.cpp.
|
private |
Logger.
Definition at line 306 of file general_executor.cpp.
|
private |
Index of context to use for transport.
Definition at line 282 of file general_executor.cpp.
|
private |
List of pairs of context and its thread for transport.
Definition at line 276 of file general_executor.cpp.