12 #ifndef THRILL_DATA_BYTE_BLOCK_HEADER 13 #define THRILL_DATA_BYTE_BLOCK_HEADER 53 static constexpr
bool debug =
false;
99 return data_ !=
nullptr;
125 std::vector<size_t, mem::GPoolAllocator<size_t> >
pin_count_;
163 int64_t offset,
size_t size);
213 :
ByteBlockPtr(pbb), local_worker_id_(pbb.local_worker_id_) {
219 :
ByteBlockPtr(std::move(pbb)), local_worker_id_(pbb.local_worker_id_) {
220 assert(!pbb.valid());
225 if (
this == &pbb)
return *
this;
227 if (pbb.valid()) pbb->IncPinCount(pbb.local_worker_id_);
232 local_worker_id_ = pbb.local_worker_id_;
238 if (
this == &pbb)
return *
this;
243 local_worker_id_ = pbb.local_worker_id_;
245 assert(!pbb.valid());
260 return std::move(*
this);
266 :
ByteBlockPtr(ptr), local_worker_id_(local_worker_id) { }
270 :
ByteBlockPtr(std::move(ptr)), local_worker_id_(local_worker_id) { }
292 #endif // !THRILL_DATA_BYTE_BLOCK_HEADER Block combines a reference to a read-only ByteBlock and book-keeping information. ...
std::vector< size_t, mem::GPoolAllocator< size_t > > pin_count_
counts the number of pins in this block per thread_id.
size_t size() const
the block size
bool is_deleted() const
true if being deleted
void OnWriteComplete(foxxll::request *req, bool success)
forwarded to block_pool_
friend std::ostream & operator<<(std::ostream &os, const ByteBlock &b)
size_t default_block_size
default size of blocks in File, Channel, BlockQueue, etc.
BlockPool * block_pool_
reference to BlockPool for deletion.
Specialization of block identifier class (BID) for variable size block size.
ReferenceCounter & operator=(const ReferenceCounter &) noexcept
assignment operator, leaves pointers unchanged
A pinned / pin-counted pointer to a ByteBlock.
tlx::CountingPtr< ByteBlock, Deleter > ByteBlockPtr
size_t local_worker_id() const
local worker id of holder of pin
PinnedByteBlockPtr(PinnedByteBlockPtr &&pbb) noexcept
move-ctor: move underlying's pin
A non-pinned counting pointer to a ByteBlock.
void IncPinCount(size_t local_worker_id)
increment pin count, must be >= 1 before.
ByteBlockPtr()=default
default ctor: returns an empty ByteBlockPtr
Byte * data()
mutable data accessor to memory block
std::string pin_count_str() const
return string list of pin_counts
void operator()(ByteBlock *bb) const
const Byte * data() const
const data accessor to memory block
PinnedByteBlockPtr(const PinnedByteBlockPtr &pbb) noexcept
copy-ctor: increment underlying's pin count
CountingPtr & operator=(const CountingPtr &other) noexcept
ByteBlock()=delete
No default construction of Byteblock.
Type * get() const noexcept
return the enclosed pointer.
A simple memory allocation manager.
foxxll::file_ptr ext_file_
ByteBlockPtr(ByteBlock *ptr)
(protected) ctor from plain pointer
size_t start_block_size
starting size of blocks in BlockWriter.
const size_t size_
the allocated size of the buffer in bytes
deleter for CountingPtr<ByteBlock>
uint8_t Byte
type of underlying memory area
Pool to allocate, keep, swap out/in, and free all ByteBlocks on the host.
A ByteBlock is the basic storage units of containers like File, BlockQueue, etc.
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
bool in_memory() const
true if block resides in memory
PinnedByteBlockPtr(ByteBlock *ptr, size_t local_worker_id) noexcept
protected ctor for calling from Acquire().
size_t pin_count(size_t local_worker_id) const
return current pin count
High-performance smart pointer used as a wrapping reference counting pointer.
~PinnedByteBlockPtr()
destructor: remove pin
const Byte * begin() const
const data accessor to beginning of memory block
bool has_ext_file() const
Returns whether the ByteBlock is in an external file.
A pinned / pin-counted derivative of a Block.
size_t local_worker_id_
local worker id of holder of pin
Byte * end()
mutable data accessor beyond end of memory block
PinnedByteBlockPtr(ByteBlockPtr &&ptr, size_t local_worker_id) noexcept
protected ctor for calling from Acquire().
Request object encapsulating basic properties like file and offset.
static constexpr bool debug
Byte * begin()
mutable data accessor to beginning of memory block
const Byte * end() const
const data accessor beyond end of memory block
ByteBlockPtr ReleasePin() &&
relinquish pin
void DecPinCount(size_t local_worker_id)
decrement pin count, possibly signal block pool that if it reaches zero.
Provides reference counting abilities for use with CountingPtr.