TAO_CosNotification  2.0.8
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
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]

List of all members.

Public Member Functions

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

Private Member Functions

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

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) [static, private]

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


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines