libmoost
|
block_store provides block-level storage by presenting a thread-safe pool of streams, for allocing, reading/writing, freeing More...
#include <block_store.hpp>
Classes | |
class | scoped_block |
Public Member Functions | |
block_store (const std::string &path, size_t block_size, size_t num_streams=8) | |
~block_store () | |
size_t | allocated () |
size_t | block_size () |
Private Member Functions | |
void | free (size_t index) |
size_t | alloc () |
std::streampos | getpos (size_t index) |
Private Attributes | |
moost::container::resource_stack < std::fstream > | m_rstreams |
size_t | m_block_size |
size_t | m_allocated |
std::vector< size_t > | m_free_list |
boost::mutex | m_mutex |
block_store provides block-level storage by presenting a thread-safe pool of streams, for allocing, reading/writing, freeing
Definition at line 49 of file block_store.hpp.
moost::io::block_store::block_store | ( | const std::string & | path, |
size_t | block_size, | ||
size_t | num_streams = 8 |
||
) | [inline] |
construct a new block store
Definition at line 144 of file block_store.hpp.
moost::io::block_store::~block_store | ( | ) | [inline] |
destroys the block_store n.b. everyone must have their hands off the block_store before you destroy it
Definition at line 180 of file block_store.hpp.
size_t moost::io::block_store::alloc | ( | ) | [inline, private] |
alloc an index and return it
Definition at line 76 of file block_store.hpp.
size_t moost::io::block_store::allocated | ( | ) | [inline] |
returns how many blocks have been allocated, including empty blocks that are in the free list
Definition at line 195 of file block_store.hpp.
size_t moost::io::block_store::block_size | ( | ) | [inline] |
returns the block size of this block store
Definition at line 201 of file block_store.hpp.
void moost::io::block_store::free | ( | size_t | index | ) | [inline, private] |
free a block at a given index, and don't whine if the index is invalid (don't want to throw on dtors)
Definition at line 60 of file block_store.hpp.
std::streampos moost::io::block_store::getpos | ( | size_t | index | ) | [inline, private] |
given an index, find the associated index within the stream
Definition at line 91 of file block_store.hpp.
size_t moost::io::block_store::m_allocated [private] |
Definition at line 54 of file block_store.hpp.
size_t moost::io::block_store::m_block_size [private] |
Definition at line 53 of file block_store.hpp.
std::vector<size_t> moost::io::block_store::m_free_list [private] |
Definition at line 55 of file block_store.hpp.
boost::mutex moost::io::block_store::m_mutex [private] |
Definition at line 56 of file block_store.hpp.
moost::container::resource_stack< std::fstream > moost::io::block_store::m_rstreams [private] |
Definition at line 52 of file block_store.hpp.