TAO_CosNotification  2.3.4
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
TAO_Notify::Persistent_File_Allocator Class Reference

A class that manages the details of persistent storage. More...

#include <Persistent_File_Allocator.h>

Collaboration diagram for TAO_Notify::Persistent_File_Allocator:
Collaboration graph
[legend]

Public Member Functions

 Persistent_File_Allocator ()
 The constructor. More...
 
 ~Persistent_File_Allocator ()
 The destructor. More...
 
bool open (const ACE_TCHAR *filename, const size_t block_size=512)
 
void shutdown ()
 Wait for pending I/O and terminate our work thread. More...
 
Persistent_Storage_Blockallocate ()
 
Persistent_Storage_Blockallocate_at (size_t block_number)
 Allocate a new Persistent_Storage_Block at a given address. More...
 
Persistent_Storage_Blockallocate_nowrite ()
 Allocate a PSB that is marked to not persist. More...
 
void used (size_t block_number)
 Mark a block as used, removing it from the free list. More...
 
void free (size_t block_number)
 Mark a block number as able to be used again. More...
 
size_t block_size () const
 Access block size. More...
 
bool read (Persistent_Storage_Block *psb)
 Read data into a PSB. More...
 
bool write (Persistent_Storage_Block *psb)
 Write this block to the file,. More...
 
ACE_OFF_T file_size () const
 for information (unit test) only. More...
 

Private Member Functions

void free_block (const size_t block_number)
 Free a previously assigned block. More...
 
bool allocate_block (size_t &block_number)
 Find and allocate a free block. More...
 
void shutdown_thread ()
 Wait for pending I/O to complete and shut our worker thread down safely. More...
 
void run ()
 The worker's execution thread. More...
 

Static Private Member Functions

static ACE_THR_FUNC_RETURN thr_func (void *arg)
 

Private Attributes

ACE_Thread_Manager thread_manager_
 
Random_File pstore_
 
Bit_Vector free_blocks_
 
ACE_Unbounded_Queue< Persistent_Storage_Block * > block_queue_
 
TAO_SYNCH_MUTEX lock_
 
TAO_SYNCH_MUTEX free_blocks_lock_
 
TAO_SYNCH_MUTEX queue_lock_
 
bool terminate_thread_
 
bool thread_active_
 
ACE_SYNCH_CONDITION wake_up_thread_
 

Detailed Description

A class that manages the details of persistent storage.

Maintains a free list, write queue, allocations of new blocks, reads, and writes. This class also manages a thread that performs background updating of a Random_File.

Todo:

this is too much for one class to do. It should be refactored.

we shouldn't arbitrarily use a thread.

Constructor & Destructor Documentation

TAO_Notify::Persistent_File_Allocator::Persistent_File_Allocator ( )

The constructor.

TAO_Notify::Persistent_File_Allocator::~Persistent_File_Allocator ( )

The destructor.

Member Function Documentation

Persistent_Storage_Block * TAO_Notify::Persistent_File_Allocator::allocate ( )

Allocate a new Persistent_Storage_Block and initialize it to an unused block of storage.

Persistent_Storage_Block * TAO_Notify::Persistent_File_Allocator::allocate_at ( size_t  block_number)

Allocate a new Persistent_Storage_Block at a given address.

bool TAO_Notify::Persistent_File_Allocator::allocate_block ( size_t &  block_number)
private

Find and allocate a free block.

Persistent_Storage_Block * TAO_Notify::Persistent_File_Allocator::allocate_nowrite ( )

Allocate a PSB that is marked to not persist.

size_t TAO_Notify::Persistent_File_Allocator::block_size ( ) const

Access block size.

ACE_OFF_T TAO_Notify::Persistent_File_Allocator::file_size ( ) const

for information (unit test) only.

void TAO_Notify::Persistent_File_Allocator::free ( size_t  block_number)

Mark a block number as able to be used again.

void TAO_Notify::Persistent_File_Allocator::free_block ( const size_t  block_number)
private

Free a previously assigned block.

bool TAO_Notify::Persistent_File_Allocator::open ( const ACE_TCHAR filename,
const size_t  block_size = 512 
)
bool TAO_Notify::Persistent_File_Allocator::read ( Persistent_Storage_Block psb)

Read data into a PSB.

Data will come either from the queue of blocks to be written, or it will be read from the file if there are no queued write requests for this block.

void TAO_Notify::Persistent_File_Allocator::run ( )
private

The worker's execution thread.

void TAO_Notify::Persistent_File_Allocator::shutdown ( )

Wait for pending I/O and terminate our work thread.

void TAO_Notify::Persistent_File_Allocator::shutdown_thread ( )
private

Wait for pending I/O to complete and shut our worker thread down safely.

ACE_THR_FUNC_RETURN TAO_Notify::Persistent_File_Allocator::thr_func ( void *  arg)
staticprivate

Used during thread startup to cast us back to ourselves and call the run() method.

void TAO_Notify::Persistent_File_Allocator::used ( size_t  block_number)

Mark a block as used, removing it from the free list.

bool TAO_Notify::Persistent_File_Allocator::write ( Persistent_Storage_Block psb)

Write this block to the file,.

Add the Persistent_Storage_Block to our write queue and let the worker thread handle writing this to the Random_File.

Member Data Documentation

ACE_Unbounded_Queue<Persistent_Storage_Block*> TAO_Notify::Persistent_File_Allocator::block_queue_
private
Bit_Vector TAO_Notify::Persistent_File_Allocator::free_blocks_
private
TAO_SYNCH_MUTEX TAO_Notify::Persistent_File_Allocator::free_blocks_lock_
private
TAO_SYNCH_MUTEX TAO_Notify::Persistent_File_Allocator::lock_
private
Random_File TAO_Notify::Persistent_File_Allocator::pstore_
private
TAO_SYNCH_MUTEX TAO_Notify::Persistent_File_Allocator::queue_lock_
private
bool TAO_Notify::Persistent_File_Allocator::terminate_thread_
private
bool TAO_Notify::Persistent_File_Allocator::thread_active_
private
ACE_Thread_Manager TAO_Notify::Persistent_File_Allocator::thread_manager_
private
ACE_SYNCH_CONDITION TAO_Notify::Persistent_File_Allocator::wake_up_thread_
private

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