Add superblock_lock method to lock_tracker.

This commit is contained in:
Joe Thornber
2013-01-07 15:30:51 +00:00
parent 2a427ca925
commit 26b97908bd
3 changed files with 23 additions and 2 deletions

View File

@ -59,6 +59,21 @@ lock_tracker::write_lock(uint64_t key)
locks_.insert(make_pair(key, -1));
}
void
lock_tracker::superblock_lock(uint64_t key)
{
if (superblock_)
throw runtime_error("superblock already held");
superblock_ = boost::optional<uint64_t>(key);
try {
write_lock(key);
} catch (...) {
superblock_ = boost::optional<uint64_t>();
}
}
void
lock_tracker::unlock(uint64_t key)
{
@ -72,6 +87,9 @@ lock_tracker::unlock(uint64_t key)
locks_.insert(make_pair(key, it->second - 1));
else
locks_.erase(key);
if (superblock_ && *superblock_ == key)
superblock_ = boost::optional<uint64_t>();
}
bool