Thrill  0.1
PinnedByteBlockPtr Class Reference

Detailed Description

A pinned / pin-counted pointer to a ByteBlock.

By holding a pin, it is a guaranteed that the ByteBlock's underlying memory is loaded in RAM. Since pins are counted per thread, the PinnedByteBlockPtr is a counting pointer plus a thread id.

Be careful to move PinnedByteBlockPtr as must as possible, since copying costs a pinning and an unpinning operation, whereas moving is free.

Definition at line 205 of file byte_block.hpp.

+ Inheritance diagram for PinnedByteBlockPtr:
+ Collaboration diagram for PinnedByteBlockPtr:

#include <byte_block.hpp>

Public Member Functions

 PinnedByteBlockPtr () noexcept=default
 default ctor: contains a nullptr pointer. More...
 
 PinnedByteBlockPtr (const PinnedByteBlockPtr &pbb) noexcept
 copy-ctor: increment underlying's pin count More...
 
 PinnedByteBlockPtr (PinnedByteBlockPtr &&pbb) noexcept
 move-ctor: move underlying's pin More...
 
 ~PinnedByteBlockPtr ()
 destructor: remove pin More...
 
size_t local_worker_id () const
 local worker id of holder of pin More...
 
PinnedByteBlockPtroperator= (PinnedByteBlockPtr &pbb) noexcept
 copy-assignment: transfer underlying's pin count More...
 
PinnedByteBlockPtroperator= (PinnedByteBlockPtr &&pbb) noexcept
 move-assignment: move underlying's pin More...
 
ByteBlockPtr ReleasePin () &&
 relinquish pin More...
 
- Public Member Functions inherited from ByteBlockPtr
 ByteBlockPtr ()=default
 default ctor: returns an empty ByteBlockPtr More...
 
- Public Member Functions inherited from CountingPtr< Type, Deleter >
 CountingPtr () noexcept
 default constructor: contains a nullptr pointer. More...
 
 CountingPtr (std::nullptr_t) noexcept
 implicit conversion from nullptr_t: contains a nullptr pointer. More...
 
 CountingPtr (Type *ptr) noexcept
 constructor from pointer: initializes new reference to ptr. More...
 
 CountingPtr (const CountingPtr &other) noexcept
 copy-constructor: also initializes new reference to ptr. More...
 
template<typename Subclass , typename = typename std::enable_if< std::is_convertible<Subclass*, Type*>::value, void>::type>
 CountingPtr (const CountingPtr< Subclass, Deleter > &other) noexcept
 copy-constructor: also initializes new reference to ptr. More...
 
 CountingPtr (CountingPtr &&other) noexcept
 move-constructor: just moves pointer, does not change reference counts. More...
 
template<typename Subclass , typename = typename std::enable_if< std::is_convertible<Subclass*, Type*>::value, void>::type>
 CountingPtr (CountingPtr< Subclass, Deleter > &&other) noexcept
 move-constructor: just moves pointer, does not change reference counts. More...
 
CountingPtroperator= (const CountingPtr &other) noexcept
 
template<typename Subclass , typename = typename std::enable_if< std::is_convertible<Subclass*, Type*>::value, void>::type>
CountingPtroperator= (const CountingPtr< Subclass, Deleter > &other) noexcept
 
CountingPtroperator= (CountingPtr &&other) noexcept
 move-assignment operator: move reference of other to current object. More...
 
template<typename Subclass , typename = typename std::enable_if< std::is_convertible<Subclass*, Type*>::value, void>::type>
CountingPtroperator= (CountingPtr< Subclass, Deleter > &&other) noexcept
 move-assignment operator: move reference of other to current object. More...
 
 ~CountingPtr ()
 destructor: decrements reference count in ptr. More...
 
Type & operator* () const noexcept
 return the enclosed object as reference. More...
 
Type * operator-> () const noexcept
 return the enclosed pointer. More...
 
Type * get () const noexcept
 return the enclosed pointer. More...
 
bool valid () const noexcept
 test for a non-nullptr pointer More...
 
 operator bool () const noexcept
 cast to bool checks for a nullptr pointer More...
 
bool empty () const noexcept
 test for a nullptr pointer More...
 
bool unique () const noexcept
 if the object is referred by this CountingPtr only More...
 
size_t use_count () const noexcept
 
void reset ()
 release contained pointer, frees object if this is the last reference. More...
 
void swap (CountingPtr &b) noexcept
 
void unify ()
 make and refer a copy if the original object was shared. More...
 
bool operator== (const CountingPtr &other) const noexcept
 test equality of only the pointer values. More...
 
bool operator!= (const CountingPtr &other) const noexcept
 test inequality of only the pointer values. More...
 
bool operator== (Type *other) const noexcept
 test equality of only the address pointed to More...
 
bool operator!= (Type *other) const noexcept
 test inequality of only the address pointed to More...
 
bool operator< (const CountingPtr &other) const noexcept
 compare the pointer values. More...
 
bool operator<= (const CountingPtr &other) const noexcept
 compare the pointer values. More...
 
bool operator> (const CountingPtr &other) const noexcept
 compare the pointer values. More...
 
bool operator>= (const CountingPtr &other) const noexcept
 compare the pointer values. More...
 
bool operator< (Type *other) const noexcept
 compare the pointer values. More...
 
bool operator<= (Type *other) const noexcept
 compare the pointer values. More...
 
bool operator> (Type *other) const noexcept
 compare the pointer values. More...
 
bool operator>= (Type *other) const noexcept
 compare the pointer values. More...
 

Private Member Functions

 PinnedByteBlockPtr (ByteBlock *ptr, size_t local_worker_id) noexcept
 protected ctor for calling from Acquire(). More...
 
 PinnedByteBlockPtr (ByteBlockPtr &&ptr, size_t local_worker_id) noexcept
 protected ctor for calling from Acquire(). More...
 

Private Attributes

size_t local_worker_id_
 local worker id of holder of pin More...
 

Additional Inherited Members

- Public Types inherited from CountingPtr< Type, Deleter >
using element_type = Type
 contained type. More...
 
- Protected Member Functions inherited from ByteBlockPtr
 ByteBlockPtr (const PinnedByteBlockPtr &p)
 (protected) ctor from PinnedByteBlockPtr More...
 
 ByteBlockPtr (PinnedByteBlockPtr &&p)
 (protected) ctor from PinnedByteBlockPtr More...
 
 ByteBlockPtr (ByteBlock *ptr)
 (protected) ctor from plain pointer More...
 

Constructor & Destructor Documentation

◆ PinnedByteBlockPtr() [1/5]

PinnedByteBlockPtr ( )
defaultnoexcept

default ctor: contains a nullptr pointer.

◆ PinnedByteBlockPtr() [2/5]

PinnedByteBlockPtr ( const PinnedByteBlockPtr pbb)
inlinenoexcept

copy-ctor: increment underlying's pin count

Definition at line 212 of file byte_block.hpp.

References ByteBlock::IncPinCount().

◆ PinnedByteBlockPtr() [3/5]

PinnedByteBlockPtr ( PinnedByteBlockPtr &&  pbb)
inlinenoexcept

move-ctor: move underlying's pin

Definition at line 218 of file byte_block.hpp.

◆ ~PinnedByteBlockPtr()

~PinnedByteBlockPtr ( )
inline

destructor: remove pin

Definition at line 250 of file byte_block.hpp.

References ByteBlock::DecPinCount().

◆ PinnedByteBlockPtr() [4/5]

PinnedByteBlockPtr ( ByteBlock ptr,
size_t  local_worker_id 
)
inlineprivatenoexcept

protected ctor for calling from Acquire().

Definition at line 265 of file byte_block.hpp.

◆ PinnedByteBlockPtr() [5/5]

PinnedByteBlockPtr ( ByteBlockPtr &&  ptr,
size_t  local_worker_id 
)
inlineprivatenoexcept

protected ctor for calling from Acquire().

Definition at line 269 of file byte_block.hpp.

Member Function Documentation

◆ local_worker_id()

size_t local_worker_id ( ) const
inline

local worker id of holder of pin

Definition at line 255 of file byte_block.hpp.

◆ operator=() [1/2]

PinnedByteBlockPtr& operator= ( PinnedByteBlockPtr pbb)
inlinenoexcept

copy-assignment: transfer underlying's pin count

Definition at line 224 of file byte_block.hpp.

References ByteBlock::DecPinCount(), and CountingPtr< Type, Deleter >::operator=().

◆ operator=() [2/2]

PinnedByteBlockPtr& operator= ( PinnedByteBlockPtr &&  pbb)
inlinenoexcept

move-assignment: move underlying's pin

Definition at line 237 of file byte_block.hpp.

References ByteBlock::DecPinCount(), and CountingPtr< Type, Deleter >::operator=().

◆ ReleasePin()

ByteBlockPtr ReleasePin ( ) &&
inline

relinquish pin

Definition at line 258 of file byte_block.hpp.

References ByteBlock::DecPinCount().

Member Data Documentation

◆ local_worker_id_

size_t local_worker_id_
private

local worker id of holder of pin

Definition at line 273 of file byte_block.hpp.


The documentation for this class was generated from the following file: