From b0882fb682d2fc2a3fded46188eb5779e2c783d9 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 19 Aug 2015 09:59:59 -0400 Subject: [PATCH] memstore: replace apply_lock with sequencer Signed-off-by: Casey Bodley --- src/os/MemStore.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/os/MemStore.cc b/src/os/MemStore.cc index 1f51f0e50f34..0fff54506ce9 100644 --- a/src/os/MemStore.cc +++ b/src/os/MemStore.cc @@ -581,8 +581,22 @@ int MemStore::queue_transactions(Sequencer *osr, TrackedOpRef op, ThreadPool::TPHandle *handle) { - // fixme: ignore the Sequencer and serialize everything. - Mutex::Locker l(apply_lock); + // because memstore operations are synchronous, we can implement the + // Sequencer with a mutex. this guarantees ordering on a given sequencer, + // while allowing operations on different sequencers to happen in parallel + struct OpSequencer : public Sequencer_impl { + std::mutex mutex; + void flush() override {} + bool flush_commit(Context*) override { return true; } + }; + + std::unique_lock lock; + if (osr) { + auto seq = reinterpret_cast(&osr->p); + if (*seq == nullptr) + *seq = new OpSequencer; + lock = std::unique_lock((*seq)->mutex); + } for (list::iterator p = tls.begin(); p != tls.end(); ++p) { // poke the TPHandle heartbeat just to exercise that code path -- 2.47.3