cpp-msgpack-rpc
0.2.0
An RPC library implementing MessagePack RPC.
Toggle main menu visibility
Loading...
Searching...
No Matches
i_async_executor.h
Go to the documentation of this file.
1
/*
2
* Copyright 2023 MusicScience37 (Kenta Kabashima)
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
20
#pragma once
21
22
#include <exception>
23
#include <functional>
24
#include <memory>
25
26
#include "
msgpack_rpc/config/executor_config.h
"
27
#include "
msgpack_rpc/executors/i_executor.h
"
28
#include "msgpack_rpc/impl/msgpack_rpc_export.h"
29
#include "
msgpack_rpc/logging/logger.h
"
30
31
namespace
msgpack_rpc::executors
{
32
37
class
IAsyncExecutor :
public
IExecutor {
38
public
:
47
virtual
void
start
() = 0;
48
55
virtual
void
stop
() = 0;
56
62
[[nodiscard]]
virtual
std::exception_ptr
last_exception
() = 0;
63
72
virtual
void
on_exception
(
73
std::function<
void
(std::exception_ptr)> exception_callback) = 0;
74
81
[[nodiscard]]
virtual
bool
is_running
() = 0;
82
83
IAsyncExecutor
(
const
IAsyncExecutor&) =
delete
;
84
IAsyncExecutor
(IAsyncExecutor&&) =
delete
;
85
IAsyncExecutor& operator=(
const
IAsyncExecutor&) =
delete
;
86
IAsyncExecutor& operator=(IAsyncExecutor&&) =
delete
;
87
89
~IAsyncExecutor
() noexcept override = default;
90
91
protected:
93
IAsyncExecutor() noexcept = default;
94
};
95
103
[[nodiscard]] MSGPACK_RPC_EXPORT
std
::shared_ptr<IAsyncExecutor>
104
create_executor
(
std
::shared_ptr<
logging
::Logger> logger,
105
const
config
::ExecutorConfig&
config
);
106
107
}
// namespace msgpack_rpc::executors
msgpack_rpc::executors::IAsyncExecutor::IAsyncExecutor
IAsyncExecutor() noexcept=default
Constructor.
msgpack_rpc::executors::IAsyncExecutor::last_exception
virtual std::exception_ptr last_exception()=0
Get the last exception thrown in asynchronous tasks.
msgpack_rpc::executors::IAsyncExecutor::stop
virtual void stop()=0
Stops operation.
msgpack_rpc::executors::IAsyncExecutor::on_exception
virtual void on_exception(std::function< void(std::exception_ptr)> exception_callback)=0
Register a function called when an exception is thrown in asynchronous tasks.
msgpack_rpc::executors::IAsyncExecutor::is_running
virtual bool is_running()=0
Check whether this executor is running.
msgpack_rpc::executors::IAsyncExecutor::start
virtual void start()=0
Start internal event loops to process asynchronous tasks.
msgpack_rpc::executors::IAsyncExecutor::~IAsyncExecutor
~IAsyncExecutor() noexcept override=default
Destructor.
executor_config.h
Definition of ExecutorConfig class.
i_executor.h
Definition of IExecutor class.
logger.h
Definition of Logger class.
msgpack_rpc::config
Namespace of configurations.
Definition
client_config.h:32
msgpack_rpc::executors
Namespace of executors to process asynchronous tasks.
Definition
asio_context_type.h:24
msgpack_rpc::executors::create_executor
std::shared_ptr< IAsyncExecutor > create_executor(std::shared_ptr< logging::Logger > logger, const config::ExecutorConfig &config)
Create an executor.
Definition
general_executor.cpp:309
msgpack_rpc::logging
Namespace of logging.
Definition
i_log_sink.h:27
std
STL namespace.
include
msgpack_rpc
executors
i_async_executor.h
Generated on
for cpp-msgpack-rpc by
1.18.0