libmoost
moost::io::block_store Class Reference

block_store provides block-level storage by presenting a thread-safe pool of streams, for allocing, reading/writing, freeing More...

#include <block_store.hpp>

Collaboration diagram for moost::io::block_store:

List of all members.

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

Detailed Description

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.


Constructor & Destructor Documentation

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.

Here is the call graph for this function:

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.

Here is the call graph for this function:


Member Function Documentation

size_t moost::io::block_store::alloc ( ) [inline, private]

alloc an index and return it

Definition at line 76 of file block_store.hpp.

Here is the caller graph for this function:

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.

returns the block size of this block store

Definition at line 201 of file block_store.hpp.

Here is the caller graph for this function:

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.

Here is the caller graph for this function:

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.

Here is the caller graph for this function:


Member Data Documentation

Definition at line 54 of file block_store.hpp.

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.

Definition at line 52 of file block_store.hpp.


The documentation for this class was generated from the following file: