Skip to content

Commit 8134051

Browse files
committed
perf(core): move runtime executor lifecycle out of headers
1 parent 160d7f4 commit 8134051

2 files changed

Lines changed: 47 additions & 30 deletions

File tree

‎include/vix/executor/RuntimeExecutor.hpp‎

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,7 @@ namespace vix::executor
5353
* @param config Runtime configuration used to create the underlying runtime.
5454
*/
5555
explicit RuntimeExecutor(
56-
const vix::runtime::RuntimeConfig &config = vix::runtime::RuntimeConfig{})
57-
: runtime_(std::make_unique<vix::runtime::Runtime>(config)),
58-
state_(std::make_shared<SharedState>()),
59-
started_(false)
60-
{
61-
}
56+
const vix::runtime::RuntimeConfig &config = vix::runtime::RuntimeConfig{});
6257

6358
/**
6459
* @brief Construct a RuntimeExecutor with an explicit worker count.
@@ -68,10 +63,7 @@ namespace vix::executor
6863
*
6964
* @param workers Number of runtime workers to use.
7065
*/
71-
explicit RuntimeExecutor(std::uint32_t workers)
72-
: RuntimeExecutor(make_config_from_workers(workers))
73-
{
74-
}
66+
explicit RuntimeExecutor(std::uint32_t workers);
7567

7668
/**
7769
* @brief Construct a RuntimeExecutor from an existing runtime instance.
@@ -80,16 +72,7 @@ namespace vix::executor
8072
*
8173
* @throw std::invalid_argument If runtime is null.
8274
*/
83-
explicit RuntimeExecutor(std::unique_ptr<vix::runtime::Runtime> runtime)
84-
: runtime_(std::move(runtime)),
85-
state_(std::make_shared<SharedState>()),
86-
started_(false)
87-
{
88-
if (!runtime_)
89-
{
90-
throw std::invalid_argument("RuntimeExecutor requires a valid runtime");
91-
}
92-
}
75+
explicit RuntimeExecutor(std::unique_ptr<vix::runtime::Runtime> runtime);
9376

9477
RuntimeExecutor(const RuntimeExecutor &) = delete;
9578
RuntimeExecutor &operator=(const RuntimeExecutor &) = delete;
@@ -100,16 +83,7 @@ namespace vix::executor
10083
/**
10184
* @brief Destroy the executor and stop the runtime safely.
10285
*/
103-
~RuntimeExecutor() noexcept
104-
{
105-
try
106-
{
107-
stop();
108-
}
109-
catch (...)
110-
{
111-
}
112-
}
86+
~RuntimeExecutor() noexcept;
11387

11488
/**
11589
* @brief Start the underlying runtime once.

‎src/executor/RuntimeExecutor.cpp‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* @file RuntimeExecutor.cpp
3+
* @brief Out-of-line lifecycle definitions for RuntimeExecutor.
4+
*/
5+
6+
#include <vix/executor/RuntimeExecutor.hpp>
7+
8+
namespace vix::executor
9+
{
10+
RuntimeExecutor::RuntimeExecutor(const vix::runtime::RuntimeConfig &config)
11+
: runtime_(std::make_unique<vix::runtime::Runtime>(config)),
12+
state_(std::make_shared<SharedState>()),
13+
started_(false)
14+
{
15+
}
16+
17+
RuntimeExecutor::RuntimeExecutor(std::uint32_t workers)
18+
: RuntimeExecutor(make_config_from_workers(workers))
19+
{
20+
}
21+
22+
RuntimeExecutor::RuntimeExecutor(std::unique_ptr<vix::runtime::Runtime> runtime)
23+
: runtime_(std::move(runtime)),
24+
state_(std::make_shared<SharedState>()),
25+
started_(false)
26+
{
27+
if (!runtime_)
28+
{
29+
throw std::invalid_argument("RuntimeExecutor requires a valid runtime");
30+
}
31+
}
32+
33+
RuntimeExecutor::~RuntimeExecutor() noexcept
34+
{
35+
try
36+
{
37+
stop();
38+
}
39+
catch (...)
40+
{
41+
}
42+
}
43+
} // namespace vix::executor

0 commit comments

Comments
 (0)