修复问题

This commit is contained in:
2026-08-09 15:30:12 +08:00
parent bc70f8c34c
commit a058242536
2 changed files with 10 additions and 2 deletions
+3 -2
View File
@@ -297,11 +297,12 @@ public:
std::invoke(std::forward<Function>(function), value_);
});
} else {
std::optional<std::remove_cvref_t<Result>> result;
using Value_Result = std::remove_cvref_t<Result>;
std::optional<Value_Result> result;
this->with_all_writable_locked([&](auto&) {
result.emplace(std::invoke(std::forward<Function>(function), value_));
});
return std::move(*result);
return Value_Result(std::move(*result));
}
}
T snapshot() const requires std::copy_constructible<T> {
+7
View File
@@ -4,6 +4,7 @@
#include "adminive_test.hpp"
#include <string>
#include <thread>
#include <tuple>
namespace managed_test {
using Json = nlohmann::json;
struct Section_Config {
@@ -108,6 +109,12 @@ int main() {
value = 12;
});
ADMINIVE_CHECK(Probe_Lock::exclusive_locks.load(std::memory_order_relaxed) == 1);
const auto [written_value, write_message] = guarded.write([](Section_Config& value) {
value.backend_value = 14;
return std::tuple{value.backend_value, std::string(128, 'x')};
});
ADMINIVE_CHECK(written_value == 14);
ADMINIVE_CHECK(write_message == std::string(128, 'x'));
Probe_Lock::reset();
unsynchronized.write([](int& value) {
value = 13;