Thrill
0.1
|
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. |
Definition at line 51 of file block_scheduler.hpp.
#include <block_scheduler.hpp>
Public Types | |
using | external_block_type = typename internal_block_type::bid_type |
using | internal_block_type = typed_block< raw_block_size, ValueType > |
Public Member Functions | |
swappable_block () | |
Create in uninitialized state. More... | |
~swappable_block () | |
internal_block_type & | acquire () |
void | attach_internal_block (internal_block_type *iblock) |
Attach an internal_block, making the block internal. Has to be not internal. More... | |
request_ptr | clean_async (completion_handler on_cmpl=completion_handler()) |
void | clean_sync () |
Write synchronously from internal_block to external_block if necessary. More... | |
internal_block_type * | deinitialize () |
internal_block_type * | detach_internal_block () |
external_block_type | extract_external_block () |
void | fill_default () |
Fill block with default data, is supposed to be overwritten by subclass. Has to be internal. More... | |
const internal_block_type & | get_internal_block () const |
Get a reference to the data-block. Has to be acquired. More... | |
internal_block_type & | get_internal_block () |
Get a reference to the data-block. Has to be acquired. More... | |
bool | has_external_block () const |
If it has an external_block. More... | |
void | initialize (external_block_type eblock) |
bool | is_acquired () const |
If it is acquired. More... | |
bool | is_dirty () const |
If the external_block does not hold valid data. More... | |
bool | is_evictable () const |
If it holds an internal_block but does not need it. More... | |
bool | is_external () const |
If it has an external_block that holds valid data. More... | |
bool | is_initialized () const |
If it has some valid data (in- or external). More... | |
bool | is_internal () const |
If it has an internal_block. The internal_block implicitly holds valid data. More... | |
bool | make_dirty_if (const bool make_dirty) |
request_ptr | read_async (completion_handler on_cmpl=completion_handler()) |
void | read_sync () |
Read synchronously from external_block to internal_block. Has to be internal and have an external_block. More... | |
void | release () |
Release the block, i.e. subduct a reference. Has to be acquired. More... | |
Protected Member Functions | |
void | free_external_block () |
void | get_external_block () |
Protected Attributes | |
bool | dirty |
external_block_type | external_data |
internal_block_type * | internal_data |
external_data.valid if no associated space on disk More... | |
size_t | reference_count |
Static Protected Attributes | |
static size_t | disk_allocation_offset = 0 |
static const size_t | raw_block_size = BlockSize * sizeof(ValueType) |
Static Private Attributes | |
static constexpr bool | debug = false |
using external_block_type = typename internal_block_type::bid_type |
Definition at line 60 of file block_scheduler.hpp.
using internal_block_type = typed_block<raw_block_size, ValueType> |
Definition at line 59 of file block_scheduler.hpp.
|
inline |
|
inline |
Definition at line 84 of file block_scheduler.hpp.
|
inline |
Acquire the block, i.e. add a reference. Has to be internal.
Definition at line 124 of file block_scheduler.hpp.
References swappable_block< ValueType, BlockSize >::internal_data, swappable_block< ValueType, BlockSize >::is_internal(), and swappable_block< ValueType, BlockSize >::reference_count.
Referenced by block_scheduler_algorithm< SwappableBlockType >::swappable_blocks_resize().
|
inline |
Attach an internal_block, making the block internal. Has to be not internal.
Definition at line 194 of file block_scheduler.hpp.
References swappable_block< ValueType, BlockSize >::is_internal().
|
inline |
Write asyncronusly from internal_block to external_block if necessary.
Definition at line 172 of file block_scheduler.hpp.
References swappable_block< ValueType, BlockSize >::get_external_block(), swappable_block< ValueType, BlockSize >::has_external_block(), swappable_block< ValueType, BlockSize >::is_dirty(), TLX_LOG, and typed_block< RawSize, Type, NRef, MetaInfoType >::write().
Referenced by swappable_block< ValueType, BlockSize >::clean_sync().
|
inline |
Write synchronously from internal_block to external_block if necessary.
Definition at line 186 of file block_scheduler.hpp.
References swappable_block< ValueType, BlockSize >::clean_async(), and CountingPtr< Type, Deleter >::valid().
Referenced by swappable_block< ValueType, BlockSize >::detach_internal_block().
|
inline |
Bring the block in uninitialized state, freeing external and internal memory. Returns a pointer to the internal_block, nullptr if it had none.
Definition at line 214 of file block_scheduler.hpp.
References swappable_block< ValueType, BlockSize >::free_external_block(), swappable_block< ValueType, BlockSize >::has_external_block(), swappable_block< ValueType, BlockSize >::internal_data, and swappable_block< ValueType, BlockSize >::is_acquired().
Referenced by block_scheduler< SwappableBlockType >::free_swappable_block(), and block_scheduler_algorithm< SwappableBlockType >::swappable_blocks_resize().
|
inline |
Detach the internal_block. Writes to external_block if necessary. Has to be evictable.
Definition at line 202 of file block_scheduler.hpp.
References swappable_block< ValueType, BlockSize >::clean_sync(), swappable_block< ValueType, BlockSize >::internal_data, and swappable_block< ValueType, BlockSize >::is_evictable().
Referenced by block_scheduler< SwappableBlockType >::flush().
|
inline |
Extract the swappable_blocks data in an external_block. The block gets uninitialized.
Definition at line 237 of file block_scheduler.hpp.
References swappable_block< ValueType, BlockSize >::external_data, and swappable_block< ValueType, BlockSize >::is_internal().
Referenced by block_scheduler_algorithm< SwappableBlockType >::swappable_blocks_resize().
|
inline |
Fill block with default data, is supposed to be overwritten by subclass. Has to be internal.
Definition at line 153 of file block_scheduler.hpp.
|
inlineprotected |
Definition at line 73 of file block_scheduler.hpp.
References block_manager::delete_block(), and singleton< block_manager >::get_instance().
Referenced by swappable_block< ValueType, BlockSize >::deinitialize().
|
inlineprotected |
Definition at line 70 of file block_scheduler.hpp.
References singleton< block_manager >::get_instance(), and block_manager::new_block().
Referenced by swappable_block< ValueType, BlockSize >::clean_async().
|
inline |
Get a reference to the data-block. Has to be acquired.
Definition at line 139 of file block_scheduler.hpp.
References swappable_block< ValueType, BlockSize >::internal_data, and swappable_block< ValueType, BlockSize >::is_acquired().
|
inline |
Get a reference to the data-block. Has to be acquired.
Definition at line 146 of file block_scheduler.hpp.
References swappable_block< ValueType, BlockSize >::internal_data, and swappable_block< ValueType, BlockSize >::is_acquired().
|
inline |
If it has an external_block.
Definition at line 95 of file block_scheduler.hpp.
Referenced by swappable_block< ValueType, BlockSize >::clean_async(), swappable_block< ValueType, BlockSize >::deinitialize(), swappable_block< ValueType, BlockSize >::is_external(), and swappable_block< ValueType, BlockSize >::read_async().
|
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. |
Definition at line 229 of file block_scheduler.hpp.
References swappable_block< ValueType, BlockSize >::is_initialized().
Referenced by block_scheduler_algorithm< SwappableBlockType >::swappable_blocks_resize().
|
inline |
If it is acquired.
Definition at line 103 of file block_scheduler.hpp.
Referenced by swappable_block< ValueType, BlockSize >::deinitialize(), swappable_block< ValueType, BlockSize >::get_internal_block(), swappable_block< ValueType, BlockSize >::is_evictable(), swappable_block< ValueType, BlockSize >::make_dirty_if(), and swappable_block< ValueType, BlockSize >::release().
|
inline |
If the external_block does not hold valid data.
Definition at line 91 of file block_scheduler.hpp.
References swappable_block< ValueType, BlockSize >::dirty.
Referenced by swappable_block< ValueType, BlockSize >::clean_async(), and swappable_block< ValueType, BlockSize >::is_external().
|
inline |
If it holds an internal_block but does not need it.
Definition at line 107 of file block_scheduler.hpp.
References swappable_block< ValueType, BlockSize >::is_acquired(), and swappable_block< ValueType, BlockSize >::is_internal().
Referenced by swappable_block< ValueType, BlockSize >::detach_internal_block().
|
inline |
If it has an external_block that holds valid data.
Definition at line 99 of file block_scheduler.hpp.
References swappable_block< ValueType, BlockSize >::has_external_block(), and swappable_block< ValueType, BlockSize >::is_dirty().
Referenced by swappable_block< ValueType, BlockSize >::is_initialized().
|
inline |
If it has some valid data (in- or external).
Definition at line 111 of file block_scheduler.hpp.
References swappable_block< ValueType, BlockSize >::is_external(), and swappable_block< ValueType, BlockSize >::is_internal().
Referenced by block_scheduler_algorithm_simulation< SwappableBlockType >::init(), and swappable_block< ValueType, BlockSize >::initialize().
|
inline |
If it has an internal_block. The internal_block implicitly holds valid data.
Definition at line 87 of file block_scheduler.hpp.
Referenced by swappable_block< ValueType, BlockSize >::acquire(), swappable_block< ValueType, BlockSize >::attach_internal_block(), swappable_block< ValueType, BlockSize >::extract_external_block(), swappable_block< ValueType, BlockSize >::is_evictable(), swappable_block< ValueType, BlockSize >::is_initialized(), and swappable_block< ValueType, BlockSize >::read_async().
|
inline |
Invalidate external data if true.
Definition at line 116 of file block_scheduler.hpp.
References swappable_block< ValueType, BlockSize >::dirty, and swappable_block< ValueType, BlockSize >::is_acquired().
|
inline |
Read asyncronusly from external_block to internal_block. Has to be internal and have an external_block.
Definition at line 157 of file block_scheduler.hpp.
References swappable_block< ValueType, BlockSize >::has_external_block(), swappable_block< ValueType, BlockSize >::is_internal(), typed_block< RawSize, Type, NRef, MetaInfoType >::read(), and TLX_LOG.
Referenced by swappable_block< ValueType, BlockSize >::read_sync().
|
inline |
Read synchronously from external_block to internal_block. Has to be internal and have an external_block.
Definition at line 167 of file block_scheduler.hpp.
References swappable_block< ValueType, BlockSize >::read_async().
|
inline |
Release the block, i.e. subduct a reference. Has to be acquired.
Definition at line 132 of file block_scheduler.hpp.
References swappable_block< ValueType, BlockSize >::is_acquired(), and swappable_block< ValueType, BlockSize >::reference_count.
Referenced by block_scheduler_algorithm< SwappableBlockType >::swappable_blocks_resize().
|
staticprivate |
Definition at line 53 of file block_scheduler.hpp.
|
protected |
Definition at line 65 of file block_scheduler.hpp.
Referenced by swappable_block< ValueType, BlockSize >::is_dirty(), swappable_block< ValueType, BlockSize >::make_dirty_if(), block_scheduler_algorithm_simulation< SwappableBlockType >::release(), and block_scheduler_algorithm_offline_lru_prefetching< SwappableBlockType >::release().
|
staticprotected |
Definition at line 68 of file block_scheduler.hpp.
|
protected |
Definition at line 63 of file block_scheduler.hpp.
Referenced by swappable_block< ValueType, BlockSize >::extract_external_block().
|
protected |
external_data.valid if no associated space on disk
Definition at line 64 of file block_scheduler.hpp.
Referenced by swappable_block< ValueType, BlockSize >::acquire(), swappable_block< ValueType, BlockSize >::deinitialize(), swappable_block< ValueType, BlockSize >::detach_internal_block(), and swappable_block< ValueType, BlockSize >::get_internal_block().
|
staticprotected |
Definition at line 56 of file block_scheduler.hpp.
|
protected |
Definition at line 66 of file block_scheduler.hpp.
Referenced by swappable_block< ValueType, BlockSize >::acquire(), and swappable_block< ValueType, BlockSize >::release().