TAO_CosNotification 4.0.0
Loading...
Searching...
No Matches
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.
 
 ~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

◆ Persistent_File_Allocator()

TAO_Notify::Persistent_File_Allocator::Persistent_File_Allocator ( )

The constructor.

◆ ~Persistent_File_Allocator()

TAO_Notify::Persistent_File_Allocator::~Persistent_File_Allocator ( )

The destructor.

Member Function Documentation

◆ allocate()

Persistent_Storage_Block * TAO_Notify::Persistent_File_Allocator::allocate ( )

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

◆ allocate_at()

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

Allocate a new Persistent_Storage_Block at a given address.

◆ allocate_block()

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

Find and allocate a free block.

◆ allocate_nowrite()

Persistent_Storage_Block * TAO_Notify::Persistent_File_Allocator::allocate_nowrite ( )

Allocate a PSB that is marked to not persist.

◆ block_size()

size_t TAO_Notify::Persistent_File_Allocator::block_size ( ) const

Access block size.

◆ file_size()

ACE_OFF_T TAO_Notify::Persistent_File_Allocator::file_size ( ) const

for information (unit test) only.

◆ free()

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

Mark a block number as able to be used again.

◆ free_block()

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

Free a previously assigned block.

◆ open()

bool TAO_Notify::Persistent_File_Allocator::open ( const ACE_TCHAR * filename,
const size_t block_size = 512 )

◆ read()

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.

◆ run()

void TAO_Notify::Persistent_File_Allocator::run ( )
private

The worker's execution thread.

◆ shutdown()

void TAO_Notify::Persistent_File_Allocator::shutdown ( )

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

◆ shutdown_thread()

void TAO_Notify::Persistent_File_Allocator::shutdown_thread ( )
private

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

◆ thr_func()

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.

◆ used()

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

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

◆ write()

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

◆ block_queue_

ACE_Unbounded_Queue<Persistent_Storage_Block*> TAO_Notify::Persistent_File_Allocator::block_queue_
private

◆ free_blocks_

Bit_Vector TAO_Notify::Persistent_File_Allocator::free_blocks_
private

◆ free_blocks_lock_

TAO_SYNCH_MUTEX TAO_Notify::Persistent_File_Allocator::free_blocks_lock_
private

◆ lock_

TAO_SYNCH_MUTEX TAO_Notify::Persistent_File_Allocator::lock_
private

◆ pstore_

Random_File TAO_Notify::Persistent_File_Allocator::pstore_
private

◆ queue_lock_

TAO_SYNCH_MUTEX TAO_Notify::Persistent_File_Allocator::queue_lock_
private

◆ terminate_thread_

bool TAO_Notify::Persistent_File_Allocator::terminate_thread_
private

◆ thread_active_

bool TAO_Notify::Persistent_File_Allocator::thread_active_
private

◆ thread_manager_

ACE_Thread_Manager TAO_Notify::Persistent_File_Allocator::thread_manager_
private

◆ wake_up_thread_

ACE_SYNCH_CONDITION TAO_Notify::Persistent_File_Allocator::wake_up_thread_
private

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