修复问题
This commit is contained in:
@@ -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> {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user