TAO_CosNotification
2.4.1
|
A class that manages the details of persistent storage. More...
#include <Persistent_File_Allocator.h>
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_Block * | allocate () |
Persistent_Storage_Block * | allocate_at (size_t block_number) |
Allocate a new Persistent_Storage_Block at a given address. More... | |
Persistent_Storage_Block * | allocate_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) |
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.
this is too much for one class to do. It should be refactored.
we shouldn't arbitrarily use a thread.
TAO_Notify::Persistent_File_Allocator::Persistent_File_Allocator | ( | ) |
The constructor.
TAO_Notify::Persistent_File_Allocator::~Persistent_File_Allocator | ( | ) |
The destructor.
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.
|
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.
|
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.
|
private |
The worker's execution thread.
void TAO_Notify::Persistent_File_Allocator::shutdown | ( | ) |
Wait for pending I/O and terminate our work thread.
|
private |
Wait for pending I/O to complete and shut our worker thread down safely.
|
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.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |