because the StoreEntry is not gone yet and may refer back to the Slot.
assert(valid(fileno));
Slot &s = shared->slots[fileno];
assert(s.state.swap_if(Slot::Writeable, Slot::Readable));
- s.releaseExclusiveLock();
+ s.switchExclusiveToSharedLock();
}
bool
assert(writers-- > 0);
}
+void
+Rock::Slot::switchExclusiveToSharedLock() const
+{
+ ++readers; // must be done before we release exclusive control
+ releaseExclusiveLock();
+}
Rock::DirMap::Shared::Shared(const int aLimit): limit(aLimit), count(0)
{
bool exclusiveLock(); ///< lock for modification or return false
void releaseSharedLock() const; ///< undo successful sharedLock()
void releaseExclusiveLock(); ///< undo successful exclusiveLock()
+ void switchExclusiveToSharedLock(); ///< trade exclusive for shared access
public:
// we want two uint64_t, but older GCCs lack __sync_fetch_and_add_8