Virtualization of a block of data. Holds information for allocating and swapping. To use in cooperation with block_scheduler. More...
#include <block_scheduler.h>


Public Types | |
|
typedef typed_block < raw_block_size, ValueType > | internal_block_type |
|
typedef internal_block_type::bid_type | external_block_type |
Public Member Functions | |
| swappable_block () | |
| Create in uninitialized state. | |
| bool | is_internal () const |
| If it has an internal_block. The internal_block implicitly holds valid data. | |
| bool | is_dirty () const |
| If the external_block does not hold valid data. | |
| bool | has_external_block () const |
| If it has an external_block. | |
| bool | is_external () const |
| If it has an external_block that holds valid data. | |
| bool | is_acquired () const |
| If it is acquired. | |
| bool | is_evictable () const |
| If it holds an internal_block but does not need it. | |
| bool | is_initialized () const |
| If it has some valid data (in- or external). | |
| bool | make_dirty_if (const bool make_dirty) |
| Invalidate external data if true. | |
| internal_block_type & | acquire () |
| Acquire the block, i.e. add a reference. Has to be internal. | |
| void | release () |
| Release the block, i.e. subduct a reference. Has to be acquired. | |
| const internal_block_type & | get_internal_block () const |
| Get a reference to the data-block. Has to be acquired. | |
| internal_block_type & | get_internal_block () |
| Get a reference to the data-block. Has to be acquired. | |
| void | fill_default () |
| Fill block with default data, is supposed to be overwritten by subclass. Has to be internal. | |
| request_ptr | read_async (completion_handler on_cmpl=default_completion_handler()) |
| Read asyncronusly from external_block to internal_block. Has to be internal and have an external_block. | |
| void | read_sync () |
| Read synchronously from external_block to internal_block. Has to be internal and have an external_block. | |
| request_ptr | clean_async (completion_handler on_cmpl=default_completion_handler()) |
| Write asyncronusly from internal_block to external_block if necessary. | |
| void | clean_sync () |
| Write synchronously from internal_block to external_block if necessary. | |
| void | attach_internal_block (internal_block_type *iblock) |
| Attach an internal_block, making the block internal. Has to be not internal. | |
| internal_block_type * | detach_internal_block () |
| Detach the internal_block. Writes to external_block if necessary. Has to be evictable. | |
| internal_block_type * | deinitialize () |
| Bring the block in uninitialized state, freeing external and internal memory. Returns a pointer to the internal_block, NULL if it had none. | |
| void | initialize (external_block_type eblock) |
| Set the external_block that holds the swappable_block's data. The block gets initialized with it. | |
| external_block_type | extract_external_block () |
| Extract the swappable_blocks data in an external_block. The block gets uninitialized. | |
Protected Member Functions | |
| void | get_external_block () |
| void | free_external_block () |
Protected Attributes | |
| external_block_type | external_data |
| internal_block_type * | internal_data |
| external_data.valid if no associated space on disk | |
| bool | dirty |
| int_type | reference_count |
Static Protected Attributes | |
| static const unsigned_type | raw_block_size = BlockSize * sizeof(ValueType) |
| static unsigned_type | disk_allocation_offset = 0 |
Virtualization of a block of data. Holds information for allocating and swapping. To use in cooperation with block_scheduler.
A swappable_block can be uninitialized, i.e. it holds no data. When access is required, is has to be acquired first, and released afterwards, so it can be swapped in and out as required. If the stored data is no longer needed, it can get uninitialized, freeing both internal and external memory.
| ValueType | type of contained objects (POD with no references to internal memory). | |
| BlockSize | Number of objects in one block. BlockSize*sizeof(ValueType) must be divisible by 4096. |
| swappable_block< ValueType, BlockSize >::swappable_block | ( | ) | [inline] |
Create in uninitialized state.
valid
| internal_block_type& swappable_block< ValueType, BlockSize >::acquire | ( | ) | [inline] |
Acquire the block, i.e. add a reference. Has to be internal.
| void swappable_block< ValueType, BlockSize >::attach_internal_block | ( | internal_block_type * | iblock | ) | [inline] |
Attach an internal_block, making the block internal. Has to be not internal.
| request_ptr swappable_block< ValueType, BlockSize >::clean_async | ( | completion_handler | on_cmpl = default_completion_handler() |
) | [inline] |
Write asyncronusly from internal_block to external_block if necessary.
Referenced by swappable_block< ValueType, BlockSideLength *BlockSideLength >::clean_sync().
| void swappable_block< ValueType, BlockSize >::clean_sync | ( | ) | [inline] |
Write synchronously from internal_block to external_block if necessary.
Referenced by swappable_block< ValueType, BlockSideLength *BlockSideLength >::detach_internal_block().
| internal_block_type* swappable_block< ValueType, BlockSize >::deinitialize | ( | ) | [inline] |
Bring the block in uninitialized state, freeing external and internal memory. Returns a pointer to the internal_block, NULL if it had none.
| internal_block_type* swappable_block< ValueType, BlockSize >::detach_internal_block | ( | ) | [inline] |
Detach the internal_block. Writes to external_block if necessary. Has to be evictable.
| external_block_type swappable_block< ValueType, BlockSize >::extract_external_block | ( | ) | [inline] |
Extract the swappable_blocks data in an external_block. The block gets uninitialized.
| void swappable_block< ValueType, BlockSize >::fill_default | ( | ) | [inline] |
Fill block with default data, is supposed to be overwritten by subclass. Has to be internal.
Reimplemented in matrix_swappable_block< ValueType, BlockSideLength >.
| const internal_block_type& swappable_block< ValueType, BlockSize >::get_internal_block | ( | ) | const [inline] |
Get a reference to the data-block. Has to be acquired.
| internal_block_type& swappable_block< ValueType, BlockSize >::get_internal_block | ( | ) | [inline] |
Get a reference to the data-block. Has to be acquired.
| bool swappable_block< ValueType, BlockSize >::has_external_block | ( | ) | const [inline] |
If it has an external_block.
Referenced by swappable_block< ValueType, BlockSideLength *BlockSideLength >::clean_async(), swappable_block< ValueType, BlockSideLength *BlockSideLength >::deinitialize(), swappable_block< ValueType, BlockSideLength *BlockSideLength >::is_external(), and swappable_block< ValueType, BlockSideLength *BlockSideLength >::read_async().
| void swappable_block< ValueType, BlockSize >::initialize | ( | external_block_type | eblock | ) | [inline] |
Set the external_block that holds the swappable_block's data. The block gets initialized with it.
| eblock | The external_block holding initial data. |
| bool swappable_block< ValueType, BlockSize >::is_acquired | ( | ) | const [inline] |
If it is acquired.
Referenced by swappable_block< ValueType, BlockSideLength *BlockSideLength >::deinitialize(), swappable_block< ValueType, BlockSideLength *BlockSideLength >::get_internal_block(), swappable_block< ValueType, BlockSideLength *BlockSideLength >::is_evictable(), swappable_block< ValueType, BlockSideLength *BlockSideLength >::make_dirty_if(), and swappable_block< ValueType, BlockSideLength *BlockSideLength >::release().
| bool swappable_block< ValueType, BlockSize >::is_dirty | ( | ) | const [inline] |
If the external_block does not hold valid data.
Referenced by swappable_block< ValueType, BlockSideLength *BlockSideLength >::clean_async(), and swappable_block< ValueType, BlockSideLength *BlockSideLength >::is_external().
| bool swappable_block< ValueType, BlockSize >::is_evictable | ( | ) | const [inline] |
If it holds an internal_block but does not need it.
Referenced by swappable_block< ValueType, BlockSideLength *BlockSideLength >::detach_internal_block().
| bool swappable_block< ValueType, BlockSize >::is_external | ( | ) | const [inline] |
If it has an external_block that holds valid data.
Referenced by swappable_block< ValueType, BlockSideLength *BlockSideLength >::is_initialized().
| bool swappable_block< ValueType, BlockSize >::is_initialized | ( | ) | const [inline] |
If it has some valid data (in- or external).
Referenced by swappable_block< ValueType, BlockSideLength *BlockSideLength >::initialize().
| bool swappable_block< ValueType, BlockSize >::is_internal | ( | ) | const [inline] |
If it has an internal_block. The internal_block implicitly holds valid data.
Referenced by swappable_block< ValueType, BlockSideLength *BlockSideLength >::acquire(), swappable_block< ValueType, BlockSideLength *BlockSideLength >::attach_internal_block(), swappable_block< ValueType, BlockSideLength *BlockSideLength >::extract_external_block(), swappable_block< ValueType, BlockSideLength *BlockSideLength >::is_evictable(), swappable_block< ValueType, BlockSideLength *BlockSideLength >::is_initialized(), and swappable_block< ValueType, BlockSideLength *BlockSideLength >::read_async().
| bool swappable_block< ValueType, BlockSize >::make_dirty_if | ( | const bool | make_dirty | ) | [inline] |
Invalidate external data if true.
| request_ptr swappable_block< ValueType, BlockSize >::read_async | ( | completion_handler | on_cmpl = default_completion_handler() |
) | [inline] |
Read asyncronusly from external_block to internal_block. Has to be internal and have an external_block.
Referenced by swappable_block< ValueType, BlockSideLength *BlockSideLength >::read_sync().
| void swappable_block< ValueType, BlockSize >::read_sync | ( | ) | [inline] |
Read synchronously from external_block to internal_block. Has to be internal and have an external_block.
| void swappable_block< ValueType, BlockSize >::release | ( | ) | [inline] |
Release the block, i.e. subduct a reference. Has to be acquired.
internal_block_type* swappable_block< ValueType, BlockSize >::internal_data [protected] |
external_data.valid if no associated space on disk
Referenced by swappable_block< ValueType, BlockSideLength *BlockSideLength >::acquire(), swappable_block< ValueType, BlockSideLength *BlockSideLength >::attach_internal_block(), swappable_block< ValueType, BlockSideLength *BlockSideLength >::clean_async(), swappable_block< ValueType, BlockSideLength *BlockSideLength >::deinitialize(), swappable_block< ValueType, BlockSideLength *BlockSideLength >::detach_internal_block(), swappable_block< ValueType, BlockSideLength *BlockSideLength >::get_internal_block(), swappable_block< ValueType, BlockSideLength *BlockSideLength >::is_internal(), and swappable_block< ValueType, BlockSideLength *BlockSideLength >::read_async().
1.7.1