[block, lock_checker] add an is_locked() method for use in unit tests.
This commit is contained in:
parent
a0f53f47aa
commit
a7c0b0c39b
@ -198,6 +198,11 @@ namespace persistent_data {
|
|||||||
|
|
||||||
void flush() const;
|
void flush() const;
|
||||||
|
|
||||||
|
|
||||||
|
// This is just for unit tests, don't call in application
|
||||||
|
// code.
|
||||||
|
bool is_locked(block_address b) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void check(block_address b) const;
|
void check(block_address b) const;
|
||||||
void write_block(typename block::ptr b) const;
|
void write_block(typename block::ptr b) const;
|
||||||
|
@ -527,4 +527,11 @@ block_manager<BlockSize>::flush() const
|
|||||||
boost::bind(&block_manager<BlockSize>::write_block, this, _1));
|
boost::bind(&block_manager<BlockSize>::write_block, this, _1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <uint32_t BlockSize>
|
||||||
|
bool
|
||||||
|
block_manager<BlockSize>::is_locked(block_address b) const
|
||||||
|
{
|
||||||
|
return tracker_.is_locked(b);
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
@ -116,5 +116,12 @@ lock_tracker::check_key(uint64_t key) const
|
|||||||
throw runtime_error("invalid key");
|
throw runtime_error("invalid key");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
lock_tracker::is_locked(uint64_t key) const
|
||||||
|
{
|
||||||
|
check_key(key);
|
||||||
|
return found(locks_.find(key));
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -37,6 +37,8 @@ namespace persistent_data {
|
|||||||
void superblock_lock(uint64_t key);
|
void superblock_lock(uint64_t key);
|
||||||
void unlock(uint64_t key);
|
void unlock(uint64_t key);
|
||||||
|
|
||||||
|
bool is_locked(uint64_t key) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::map<uint64_t, int> LockMap;
|
typedef std::map<uint64_t, int> LockMap;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user