fix(wave11): resolve adversarial review findings in EventBus, IO, and Runtime

This commit is contained in:
faumaray committed 2026-12-01 22:03:35 +03:00
1 parent 7bea7df46d
commit c6de7842f7
10 files changed
+871 -134

No files matched your search

+79
View File
@@ -14,6 +14,7 @@
#include <cstddef>
#include <cstdint>
#include <filesystem>
#include <latch>
#include <mutex>
#include <optional>
#include <string>
@@ -692,3 +693,81 @@ Void::Testing::Test runtime_moved_from_host_safe_defaults()
h1.begin_shutdown();
}
Void::Testing::Test runtime_begin_shutdown_during_start_prevents_ready()
{
const std::size_t baseline = settle_baseline_tasks();
Options opts;
opts.cpu_workers = 1;
opts.file_workers = 1;
opts.io.preference = Void::IO::BackendPreference::mock;
auto host_res = Host::create(opts);
require(host_res.has_value());
Host host = std::move(*host_res);
bool invoked = false;
auto sr = host.start(StartOptions{
.before_step = [&](StartStep step) -> Void::Result::Result<void> {
if (step == StartStep::components && !invoked) {
invoked = true;
std::thread t([&]() { host.begin_shutdown(); });
t.join();
}
return {};
},
});
require(sr.has_value());
expect(invoked);
expect(!host.is_ready());
expect(host.state() == HostState::stopping_admission);
std::atomic<bool> flag{false};
auto spw = host.spawn(set_flag_task(&flag));
expect(!spw.has_value());
expect(spw.error() == Void::Async::AdmissionError::stopped);
auto rep = host.shutdown_blocking();
require(rep.has_value());
expect(rep->complete);
expect(rep->state == HostState::stopped);
expect_eq(wait_for_task_count(baseline), baseline);
}
Void::Testing::Test runtime_concurrent_shutdown_waits_for_start_tsan()
{
const std::size_t baseline = settle_baseline_tasks();
Options opts;
opts.cpu_workers = 1;
opts.file_workers = 1;
opts.io.preference = Void::IO::BackendPreference::mock;
auto host_res = Host::create(opts);
require(host_res.has_value());
Host host = std::move(*host_res);
std::latch entered_components{1};
std::optional<Void::Result::Result<Void::Runtime::ShutdownReport>> sd_res;
std::thread stopper([&]() {
entered_components.wait();
sd_res = host.shutdown_blocking();
});
auto sr = host.start(StartOptions{
.before_step = [&](StartStep step) -> Void::Result::Result<void> {
if (step == StartStep::components) {
entered_components.count_down();
std::this_thread::sleep_for(10ms);
}
return {};
},
});
stopper.join();
require(sr.has_value());
require(sd_res.has_value() && sd_res->has_value());
expect((*sd_res)->complete);
expect(host.state() == HostState::stopped);
expect(!host.is_ready());
expect_eq(wait_for_task_count(baseline), baseline);
}