18 busy.clear(std::memory_order_release);
23 values = std::move(other.values);
24 busy.clear(std::memory_order_release);
29 bool try_get_copy(
size_t col_index, std::string& out)
const {
30 row_overlay_lock_guard lock(
this);
31 auto it = values.find(col_index);
32 if (it == values.end()) {
49 row_overlay_lock_guard lock(
this);
50 auto it = values.find(col_index);
51 if (it == values.end()) {
59 void set(
size_t col_index, std::string value) {
60 row_overlay_lock_guard lock(
this);
61 values[col_index] = std::move(value);
65 row_overlay_lock_guard lock(
this);
66 return values.empty();
69 RowOverlay snapshot()
const {
70 row_overlay_lock_guard lock(
this);
72 result.values = values;
77 struct row_overlay_lock_guard {
78 explicit row_overlay_lock_guard(
const RowOverlay* overlay)
79 : busy(const_cast<std::atomic_flag&>(overlay->busy)) {
80 while (busy.test_and_set(std::memory_order_acquire)) {}
83 ~row_overlay_lock_guard() {
84 busy.clear(std::memory_order_release);
87 std::atomic_flag& busy;
90 mutable std::atomic_flag busy = ATOMIC_FLAG_INIT;
91 std::unordered_map<size_t, std::string> values;
101 owned(std::move(other.owned)) {
103 ptr.store(overlay, std::memory_order_release);
104 other.ptr.store(
nullptr, std::memory_order_release);
108 if (
this != &other) {
109 owned = std::move(other.owned);
111 ptr.store(overlay, std::memory_order_release);
112 other.ptr.store(
nullptr, std::memory_order_release);
119 return ptr.load(std::memory_order_acquire);
123 return ptr.load(std::memory_order_acquire);
130 overlay = owned.get();
131 ptr.store(overlay, std::memory_order_release);
138 std::atomic<RowOverlay*> ptr;
139 std::unique_ptr<RowOverlay> owned;