12 #ifndef THRILL_DATA_BLOCK_HEADER 13 #define THRILL_DATA_BLOCK_HEADER 66 size_t begin,
size_t end,
size_t first_item,
size_t num_items,
122 static constexpr
bool debug =
false;
166 size_t begin,
size_t end,
size_t first_item,
size_t num_items,
169 begin, end, first_item, num_items, typecode_verify),
170 local_worker_id_(
byte_block.local_worker_id()) {
171 LOG <<
"PinnedBlock::Acquire() from new PinnedByteBlock" 172 <<
" for local_worker_id=" << local_worker_id_;
177 :
Block(pb), local_worker_id_(pb.local_worker_id_) {
183 :
Block(std::move(pb)), local_worker_id_(pb.local_worker_id_) {
184 assert(!pb.byte_block_);
189 if (
this == &pb)
return *
this;
191 if (pb.byte_block_) pb.
byte_block_->IncPinCount(pb.local_worker_id_);
196 local_worker_id_ = pb.local_worker_id_;
202 if (
this == &pb)
return *
this;
207 local_worker_id_ = pb.local_worker_id_;
209 assert(!pb.byte_block_);
286 return Block(std::move(*
this));
300 if (pbb.valid()) pbb->IncPinCount(local_worker_id_);
321 :
Block(b), local_worker_id_(local_worker_id) { }
338 bool ready()
const {
return ready_; }
347 : block_pool_(block_pool), block_(
std::move(block)), ready_(ready) { }
370 #endif // !THRILL_DATA_BLOCK_HEADER PinnedBlock PinWait(size_t local_worker_id) const
Convenience function to call Pin() and wait for the future.
Block combines a reference to a read-only ByteBlock and book-keeping information. ...
bool typecode_verify() const
return typecode_verify from Block
size_t pin_count(size_t local_worker_id) const
return number of pins in underlying ByteBlock
ByteBlockPtr & byte_block()
mutable access to byte_block_
PinnedBlock(const Block &b, size_t local_worker_id)
size_t num_items() const
return number of items beginning in this block
size_t first_item_absolute() const
accessor to first_item_ (absolute in ByteBlock)
const Byte * data_end() const
return pointer to end of valid data
size_t first_item_relative() const
return the first_item_offset relative to data_begin().
Block(ByteBlockPtr &&byte_block, size_t begin, size_t end, size_t first_item, size_t num_items, bool typecode_verify)
A pinned / pin-counted pointer to a ByteBlock.
void reset()
release contained pointer, frees object if this is the last reference.
PinnedBlock(const PinnedBlock &pb) noexcept
copy-ctor: increment underlying's pin count
void set_end(size_t i)
accessor to end_
A non-pinned counting pointer to a ByteBlock.
size_t local_worker_id_
thread id of holder of pin
size_t size() const
return length of valid data in bytes.
Block ToBlock() const
extract Block has an unpinned copy
size_t first_item_relative() const
return the first_item_offset relative to data_begin().
void set_begin(size_t i)
accessor to begin_
size_t size() const
return length of valid data in bytes.
Type * get() const noexcept
return the enclosed pointer.
void Reset()
release pin on block and reset Block pointer to nullptr
size_t first_item_absolute() const
accessor to first_item_ (absolute in ByteBlock)
Block & operator=(const Block &other)=default
A simple memory allocation manager.
BlockPool * block_pool_
reference back to BlockPool
ByteBlockPtr & byte_block()
uint8_t Byte
type of underlying memory area
Pool to allocate, keep, swap out/in, and free all ByteBlocks on the host.
ByteBlockPtr & byte_block()
mutable access to byte_block_
void set_end(size_t i)
accessor to end_
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
ByteBlockPtr byte_block_
referenced ByteBlock
Block MoveToBlock() &&
extract Block has an unpinning move
foxxll::request_ptr req_
running read request
PinRequestPtr Pin(size_t local_worker_id) const
const ByteBlockPtr & byte_block() const
access to byte_block_
PinRequest(BlockPool *block_pool, PinnedBlock &&block, bool ready=true)
size_t pin_count(size_t local_worker_id) const
return number of pins in underlying ByteBlock
High-performance smart pointer used as a wrapping reference counting pointer.
size_t num_items() const
return number of items beginning in this block
A pinned / pin-counted derivative of a Block.
PinnedBlock(PinnedByteBlockPtr &&byte_block, size_t begin, size_t end, size_t first_item, size_t num_items, bool typecode_verify)
std::atomic< bool > ready_
indication that the PinnedBlocks ready
Request object encapsulating basic properties like file and offset.
PinnedBlock(PinnedBlock &&pb) noexcept
move-ctor: move underlying's pin
bool typecode_verify() const
Returns typecode_verify_.
tlx::CountingPtr< PinRequest, mem::GPoolDeleter< PinRequest > > PinRequestPtr
PinnedByteBlockPtr CopyPinnedByteBlock() const
size_t begin_
beginning offset of valid bytes to read
PinnedByteBlockPtr StealPinnedByteBlock() &&
friend std::ostream & operator<<(std::ostream &os, const Block &b)
bool ready() const
whether the read is completed, cannot block.
#define LOG
Default logging method: output if the local debug variable is true.
bool IsValid() const
Return whether the enclosed ByteBlock is valid.
const Byte * data_begin() const
return pointer to beginning of valid data
static constexpr bool debug
void set_begin(size_t i)
accessor to begin_
Provides reference counting abilities for use with CountingPtr.
bool IsValid() const
Return whether the enclosed ByteBlock is valid.
const ByteBlockPtr & byte_block() const
access to byte_block_
Block()=default
default-ctor: create invalid Block.