#include <df.h>
df_Datablock class is a wrapper class around raw memory buffer. It synchronises access to the memory block among a writer and reader(s).
It is used by df_BlockManager.
Definition at line 54 of file df.h.
Public Member Functions | |
| df_DataBlock (UInt8_t *a_block, const UInt32_t a_size) | |
| bool | IsEmpty () const |
| bool | IsClosed () const |
| void | SetBlockID (UInt32_t a_blkID) |
| UInt32_t | GetBlockID () const |
| UInt8_t * | GetData () const |
| UInt32_t | GetBlockSize () const |
| UInt32_t | GetUsedSize () const |
| UInt32_t | GetFreeSize () const |
| How much space is there to be processed? Used by the writer. | |
| UInt8_t * | GetPosition () const |
| Returns a pointer to the beginning of the free space. | |
| void | Move (UInt32_t a_amount) |
| Writing or reading data of a block is just increasing the amount of used space (a "virtual" pointer to the beginning of free space in a block). | |
| void | Close (UInt32_t a_numReaders) |
| Marks the block closed. | |
| void | Release () |
| Each reader must release the block after it is finished with it. | |
| void | Delete () |
| Deleting is resetting the amount of used space. | |
| void | Wipe () |
| Currently not used. | |
Public Attributes | |
| log_CLASSID_m | |
Private Member Functions | |
| virtual | ~df_DataBlock () |
Private Attributes | |
| UInt8_t * | m_block |
| const UInt32_t | m_size |
| Size of the data block df_DataBlock::m_block. | |
| UInt32_t | m_used |
| How much of the block space is already used (written or read by front end). | |
| bool | m_closed |
| Writing to closed block is prevented. | |
| UInt32_t | m_numReaders |
| How many back-ends are left to finish processing this block. | |
| UInt32_t | m_blockID |
| Arbitrary block identification (e.g. | |
Friends | |
| class | df_BlockManager |
| class | fsc_nsFSrecovery |
| df_DataBlock::~df_DataBlock | ( | ) | [private, virtual] |
| bool df_DataBlock::IsEmpty | ( | ) | const [inline] |
Definition at line 85 of file df.h.
Referenced by Close(), df_Unpacker::GetNextBlock(), bea_MigrationThread::Migrate(), df_BlockReader::ReleaseAndGetNextBlock(), and df_MgrWriter::~df_MgrWriter().
00085 { return (m_used == 0); };

| bool df_DataBlock::IsClosed | ( | ) | const [inline] |
Definition at line 86 of file df.h.
Referenced by df_Writer::GetNewBlock(), df_BlockManager::Release(), and df_MgrWriter::~df_MgrWriter().
00086 { return m_closed; };

| void df_DataBlock::SetBlockID | ( | UInt32_t | a_blkID | ) | [inline] |
Definition at line 88 of file df.h.
Referenced by bea_VolumeReader::Run().
00088 { m_blockID = a_blkID; };

| UInt32_t df_DataBlock::GetBlockID | ( | ) | const [inline] |
Definition at line 89 of file df.h.
Referenced by df_BlockReader::GetNextBlock(), and df_BlockReader::GetRawNextBlock().
00089 { return m_blockID; };

| UInt8_t* df_DataBlock::GetData | ( | ) | const [inline] |
Definition at line 90 of file df.h.
Referenced by df_Unpacker::GetBSData(), df_Unpacker::GetNextBlock(), df_BlockReader::GetNextBlock(), df_BlockReader::GetRawNextBlock(), and bea_MigrationThread::Migrate().
00090 { return m_block; };

| UInt32_t df_DataBlock::GetBlockSize | ( | ) | const [inline] |
Definition at line 91 of file df.h.
Referenced by df_Unpacker::GetBSData(), and bea_FRI::ReadFRI().
00091 { return m_size; };

| UInt32_t df_DataBlock::GetUsedSize | ( | ) | const [inline] |
Definition at line 92 of file df.h.
Referenced by fsc_nsFSrecovery::FlushBlock(), df_Writer::FlushBlock(), and fsc_nsFSrecovery::~fsc_nsFSrecovery().
00092 { return m_used; };

| UInt32_t df_DataBlock::GetFreeSize | ( | ) | const |
How much space is there to be processed? Used by the writer.
Definition at line 101 of file df_datablock.cpp.
References m_closed, m_size, and m_used.
Referenced by df_BlockProxyWriter::Allocate(), df_BlockProxyWriter::AllocateRawBlock(), Close(), df_BlockProxyWriter::GetFreeSize(), Move(), blk_NetReader::Run(), blk_BufferReader::Run(), and bea_VolumeReader::Run().
00101 { 00102 if (m_closed) { 00103 return 0; 00104 } 00105 else{ 00106 return (m_size - m_used); 00107 } 00108 }

| UInt8_t * df_DataBlock::GetPosition | ( | ) | const |
Returns a pointer to the beginning of the free space.
Used by the writer.
| ivd_InternalError(ie_DF_BLOCKFULL) |
Definition at line 115 of file df_datablock.cpp.
References ie_DF_BLOCKFULL, log_FUNC_m, m_block, m_closed, and m_used.
Referenced by df_BlockProxyWriter::Allocate(), df_BlockProxyWriter::AllocateRawBlock(), Close(), df_BlockProxyWriter::Go(), df_BlockProxyWriter::Move(), bea_FRI::ReadFRI(), blk_NetReader::Run(), blk_BufferReader::Run(), and bea_VolumeReader::Run().
00115 { 00116 if (m_closed) { 00117 log_FUNC_m(GetPosition); 00118 throw ivd_InternalError(ie_DF_BLOCKFULL, "Block is already closed."); 00119 } 00120 return (UInt8_t*)(m_block + m_used); 00121 }

| void df_DataBlock::Move | ( | UInt32_t | a_amount | ) |
Writing or reading data of a block is just increasing the amount of used space (a "virtual" pointer to the beginning of free space in a block).
| a_amount | The amount of data that has been written to the block. |
| ivd_InternalError(ie_DF_BLOCKFULL) |
Definition at line 81 of file df_datablock.cpp.
References cmn_Num2Str(), GetFreeSize(), ie_DF_BLOCKFULL, log_FUNC_m, m_closed, and m_used.
Referenced by df_BlockProxyWriter::Allocate(), df_BlockProxyWriter::Go(), df_BlockProxyWriter::Move(), bea_FRI::ReadFRI(), blk_NetReader::Run(), blk_BufferReader::Run(), and bea_VolumeReader::Run().
00081 { 00082 if (m_closed) { 00083 log_FUNC_m(Move); 00084 throw ivd_InternalError(ie_DF_BLOCKFULL); 00085 } 00086 00087 if (GetFreeSize() < a_amount) { 00088 log_FUNC_m(Move); 00089 throw ivd_InternalError(ie_DF_BLOCKFULL, 00090 "Free: " + cmn_Num2Str(GetFreeSize()) + 00091 " req: " + cmn_Num2Str(a_amount)); 00092 } 00093 m_used += a_amount; 00094 }


| void df_DataBlock::Close | ( | UInt32_t | a_numReaders | ) |
Marks the block closed.
Nothing can be written to/read from the block until it is released. Used by writer.
Data block after useful data is filled with zeroes. That allows better compression on tape. However, if the block is logically completelly empty it is not wiped for performance optimization reasons.
| a_numReaders | The number of readers that will process this block, before it is released. |
Definition at line 136 of file df_datablock.cpp.
References GetFreeSize(), GetPosition(), IsEmpty(), log_FUNC_INT_m, m_closed, and m_numReaders.
Referenced by df_BlockManager::Flush().
00136 { 00137 log_FUNC_INT_m(Close); 00138 00139 // Do not wipe out the block if it is completely empty. 00140 // The user of the class must detect that the block is logically empty. 00141 if ( !IsEmpty()) { 00142 UInt32_t wipeSize = GetFreeSize(); 00143 memset(GetPosition(), 0, wipeSize); 00144 }; 00145 00146 m_closed = true; 00147 m_numReaders = a_numReaders; 00148 }


| void df_DataBlock::Release | ( | ) |
Each reader must release the block after it is finished with it.
df_DataBlock::m_readers gets decreased at each call.
Last reader also re-opens data block (sets df_DataBlock::m_closed to false) and deletes it (with Delete()).
Definition at line 160 of file df_datablock.cpp.
References Delete(), log_FUNC_INT_m, m_blockID, m_closed, and m_numReaders.
Referenced by df_BlockManager::Release().
00160 { 00161 log_FUNC_INT_m(Release); 00162 00163 m_numReaders--; 00164 if (m_numReaders == 0) { 00165 m_closed = false; 00166 m_blockID = 0; 00167 Delete(); 00168 } 00169 }


| void df_DataBlock::Delete | ( | ) |
Deleting is resetting the amount of used space.
Called by Release().
Definition at line 172 of file df_datablock.cpp.
References m_used.
Referenced by fsc_nsFSrecovery::FlushBlock(), Release(), and Wipe().
00172 { 00173 m_used = 0; 00174 }

| void df_DataBlock::Wipe | ( | ) |
Currently not used.
Wipe the whole contents of a block with zeroes?
Definition at line 179 of file df_datablock.cpp.
References Delete(), and log_FUNC_m.
00179 { 00180 log_FUNC_m(Wipe); 00181 00182 // Zero memory? 00183 Delete(); 00184 }

friend class df_BlockManager [friend] |
friend class fsc_nsFSrecovery [friend] |
UInt8_t* df_DataBlock::m_block [private] |
const UInt32_t df_DataBlock::m_size [private] |
Size of the data block df_DataBlock::m_block.
Definition at line 68 of file df.h.
Referenced by GetFreeSize().
UInt32_t df_DataBlock::m_used [private] |
How much of the block space is already used (written or read by front end).
Definition at line 71 of file df.h.
Referenced by Delete(), GetFreeSize(), GetPosition(), and Move().
bool df_DataBlock::m_closed [private] |
Writing to closed block is prevented.
Reopen at Delete(), which is called by Release() of the last back end.
Definition at line 75 of file df.h.
Referenced by Close(), GetFreeSize(), GetPosition(), Move(), and Release().
UInt32_t df_DataBlock::m_numReaders [private] |
UInt32_t df_DataBlock::m_blockID [private] |
1.5.6