cpp-msgpack-rpc 0.2.0
An RPC library implementing MessagePack RPC.
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
28#include "msgpack_rpc/impl/msgpack_rpc_export.h"
30
31namespace msgpack_rpc::executors {
32
37class IAsyncExecutor : public IExecutor {
38public:
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
91protected:
93 IAsyncExecutor() noexcept = default;
94};
95
103[[nodiscard]] MSGPACK_RPC_EXPORT std::shared_ptr<IAsyncExecutor>
104create_executor(std::shared_ptr<logging::Logger> logger,
105 const config::ExecutorConfig& config);
106
107} // namespace msgpack_rpc::executors
IAsyncExecutor() noexcept=default
Constructor.
virtual std::exception_ptr last_exception()=0
Get the last exception thrown in asynchronous tasks.
virtual void stop()=0
Stops operation.
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.
virtual bool is_running()=0
Check whether this executor is running.
virtual void start()=0
Start internal event loops to process asynchronous tasks.
~IAsyncExecutor() noexcept override=default
Destructor.
Definition of ExecutorConfig class.
Definition of IExecutor class.
Definition of Logger class.
Namespace of configurations.
Namespace of executors to process asynchronous tasks.
std::shared_ptr< IAsyncExecutor > create_executor(std::shared_ptr< logging::Logger > logger, const config::ExecutorConfig &config)
Create an executor.
Namespace of logging.
Definition i_log_sink.h:27
STL namespace.