| 970 | } |
| 971 | |
| 972 | void TipCache::deallocateSnapshotSlot(SnapshotHandle slotNumber) |
| 973 | { |
| 974 | // Note: callers of this function assume that it cannot remap |
| 975 | // shared memory (as they keep shared memory pointers). |
| 976 | |
| 977 | SnapshotList* snapshots = m_snapshots->getHeader(); |
| 978 | |
| 979 | // At first, make slot available for allocator (this is always safe) |
| 980 | if (snapshots->min_free_slot > slotNumber) |
| 981 | snapshots->min_free_slot = slotNumber; |
| 982 | |
| 983 | SnapshotData* slot = snapshots->slots + slotNumber; |
| 984 | |
| 985 | slot->snapshot.store(0, std::memory_order_release); |
| 986 | slot->attachment_id.store(0, std::memory_order_release); |
| 987 | |
| 988 | // After we completed deallocation, update used slots count, if necessary |
| 989 | if (slotNumber == snapshots->slots_used.load(std::memory_order_relaxed) - 1) |
| 990 | { |
| 991 | do { |
| 992 | slot--; |
| 993 | } while (slot >= snapshots->slots && slot->attachment_id.load(std::memory_order_relaxed) == 0); |
| 994 | |
| 995 | snapshots->slots_used.store(static_cast<ULONG>(slot - snapshots->slots + 1), std::memory_order_release); |
| 996 | } |
| 997 | } |
| 998 | |
| 999 | void TipCache::endSnapshot(thread_db* tdbb, SnapshotHandle handle, AttNumber attachmentId) |
| 1000 | { |