Itoyori  v0.0.1
ityr::checkout_span< T, Mode > Class Template Reference

Checkout span to automatically manage the lifetime of checked-out memory. More...

#include <checkout_span.hpp>

Public Types

using element_type = T
 
using value_type = std::remove_cv_t< element_type >
 
using size_type = std::size_t
 
using pointer = element_type *
 
using const_pointer = std::add_const_t< element_type > *
 
using difference_type = typename std::iterator_traits< pointer >::difference_type
 
using reference = typename std::iterator_traits< pointer >::reference
 
using const_reference = typename std::iterator_traits< const_pointer >::reference
 
using iterator = pointer
 
using const_iterator = const_pointer
 
using reverse_iterator = std::reverse_iterator< iterator >
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 

Public Member Functions

 checkout_span ()
 
 checkout_span (ori::global_ptr< T > gptr, std::size_t n, Mode)
 Construct a checkout span by checking out a global memory region. More...
 
 ~checkout_span ()
 Perform the checkin operation when destroyed. More...
 
 checkout_span (const checkout_span &)=delete
 
checkout_spanoperator= (const checkout_span &)=delete
 
 checkout_span (checkout_span &&cs)
 
checkout_spanoperator= (checkout_span &&cs)
 
constexpr pointer data () const noexcept
 
constexpr size_type size () const noexcept
 
constexpr iterator begin () const noexcept
 
constexpr iterator end () const noexcept
 
constexpr const_iterator cbegin () const noexcept
 
constexpr const_iterator cend () const noexcept
 
constexpr reverse_iterator rbegin () const noexcept
 
constexpr reverse_iterator rend () const noexcept
 
constexpr const_reverse_iterator crbegin () const noexcept
 
constexpr const_reverse_iterator crend () const noexcept
 
constexpr reference operator[] (size_type i) const
 
constexpr reference front () const
 
constexpr reference back () const
 
constexpr bool empty () const noexcept
 
void checkout (ori::global_ptr< T > gptr, std::size_t n, Mode)
 Manually perform the checkout operation by checking in the previous span. More...
 
void checkout_nb (ori::global_ptr< T > gptr, std::size_t n, Mode)
 Manually perform the nonblocking checkout operation by checking in the previous span. More...
 
void checkin ()
 Manually perform the checkin operation by discarding the current checkout span. More...
 

Detailed Description

template<typename T, typename Mode>
class ityr::checkout_span< T, Mode >

Checkout span to automatically manage the lifetime of checked-out memory.

A global memory region can be checked out at the constructor and checked in at the destructor. The checkout span can be moved but cannot be copied, in order to ensure the checkin operation is performed only once. The checkout span can be used as in std::span (C++20) to access elements in the checked-out memory region.

ityr::make_checkout() is a helper function to create the checkout span.

See also
ityr::make_checkout().

Member Typedef Documentation

◆ const_iterator

template<typename T , typename Mode >
using ityr::checkout_span< T, Mode >::const_iterator = const_pointer

◆ const_pointer

template<typename T , typename Mode >
using ityr::checkout_span< T, Mode >::const_pointer = std::add_const_t<element_type>*

◆ const_reference

template<typename T , typename Mode >
using ityr::checkout_span< T, Mode >::const_reference = typename std::iterator_traits<const_pointer>::reference

◆ const_reverse_iterator

template<typename T , typename Mode >
using ityr::checkout_span< T, Mode >::const_reverse_iterator = std::reverse_iterator<const_iterator>

◆ difference_type

template<typename T , typename Mode >
using ityr::checkout_span< T, Mode >::difference_type = typename std::iterator_traits<pointer>::difference_type

◆ element_type

template<typename T , typename Mode >
using ityr::checkout_span< T, Mode >::element_type = T

◆ iterator

template<typename T , typename Mode >
using ityr::checkout_span< T, Mode >::iterator = pointer

◆ pointer

template<typename T , typename Mode >
using ityr::checkout_span< T, Mode >::pointer = element_type*

◆ reference

template<typename T , typename Mode >
using ityr::checkout_span< T, Mode >::reference = typename std::iterator_traits<pointer>::reference

◆ reverse_iterator

template<typename T , typename Mode >
using ityr::checkout_span< T, Mode >::reverse_iterator = std::reverse_iterator<iterator>

◆ size_type

template<typename T , typename Mode >
using ityr::checkout_span< T, Mode >::size_type = std::size_t

◆ value_type

template<typename T , typename Mode >
using ityr::checkout_span< T, Mode >::value_type = std::remove_cv_t<element_type>

Constructor & Destructor Documentation

◆ checkout_span() [1/4]

template<typename T , typename Mode >
ityr::checkout_span< T, Mode >::checkout_span ( )
inline

◆ checkout_span() [2/4]

template<typename T , typename Mode >
ityr::checkout_span< T, Mode >::checkout_span ( ori::global_ptr< T >  gptr,
std::size_t  n,
Mode   
)
inlineexplicit

Construct a checkout span by checking out a global memory region.

◆ ~checkout_span()

template<typename T , typename Mode >
ityr::checkout_span< T, Mode >::~checkout_span ( )
inline

Perform the checkin operation when destroyed.

◆ checkout_span() [3/4]

template<typename T , typename Mode >
ityr::checkout_span< T, Mode >::checkout_span ( const checkout_span< T, Mode > &  )
delete

◆ checkout_span() [4/4]

template<typename T , typename Mode >
ityr::checkout_span< T, Mode >::checkout_span ( checkout_span< T, Mode > &&  cs)
inline

Member Function Documentation

◆ back()

template<typename T , typename Mode >
constexpr reference ityr::checkout_span< T, Mode >::back ( ) const
inlineconstexpr

◆ begin()

template<typename T , typename Mode >
constexpr iterator ityr::checkout_span< T, Mode >::begin ( ) const
inlineconstexprnoexcept

◆ cbegin()

template<typename T , typename Mode >
constexpr const_iterator ityr::checkout_span< T, Mode >::cbegin ( ) const
inlineconstexprnoexcept

◆ cend()

template<typename T , typename Mode >
constexpr const_iterator ityr::checkout_span< T, Mode >::cend ( ) const
inlineconstexprnoexcept

◆ checkin()

template<typename T , typename Mode >
void ityr::checkout_span< T, Mode >::checkin ( )
inline

Manually perform the checkin operation by discarding the current checkout span.

◆ checkout()

template<typename T , typename Mode >
void ityr::checkout_span< T, Mode >::checkout ( ori::global_ptr< T >  gptr,
std::size_t  n,
Mode   
)
inline

Manually perform the checkout operation by checking in the previous span.

◆ checkout_nb()

template<typename T , typename Mode >
void ityr::checkout_span< T, Mode >::checkout_nb ( ori::global_ptr< T >  gptr,
std::size_t  n,
Mode   
)
inline

Manually perform the nonblocking checkout operation by checking in the previous span.

◆ crbegin()

template<typename T , typename Mode >
constexpr const_reverse_iterator ityr::checkout_span< T, Mode >::crbegin ( ) const
inlineconstexprnoexcept

◆ crend()

template<typename T , typename Mode >
constexpr const_reverse_iterator ityr::checkout_span< T, Mode >::crend ( ) const
inlineconstexprnoexcept

◆ data()

template<typename T , typename Mode >
constexpr pointer ityr::checkout_span< T, Mode >::data ( ) const
inlineconstexprnoexcept

◆ empty()

template<typename T , typename Mode >
constexpr bool ityr::checkout_span< T, Mode >::empty ( ) const
inlineconstexprnoexcept

◆ end()

template<typename T , typename Mode >
constexpr iterator ityr::checkout_span< T, Mode >::end ( ) const
inlineconstexprnoexcept

◆ front()

template<typename T , typename Mode >
constexpr reference ityr::checkout_span< T, Mode >::front ( ) const
inlineconstexpr

◆ operator=() [1/2]

template<typename T , typename Mode >
checkout_span& ityr::checkout_span< T, Mode >::operator= ( checkout_span< T, Mode > &&  cs)
inline

◆ operator=() [2/2]

template<typename T , typename Mode >
checkout_span& ityr::checkout_span< T, Mode >::operator= ( const checkout_span< T, Mode > &  )
delete

◆ operator[]()

template<typename T , typename Mode >
constexpr reference ityr::checkout_span< T, Mode >::operator[] ( size_type  i) const
inlineconstexpr

◆ rbegin()

template<typename T , typename Mode >
constexpr reverse_iterator ityr::checkout_span< T, Mode >::rbegin ( ) const
inlineconstexprnoexcept

◆ rend()

template<typename T , typename Mode >
constexpr reverse_iterator ityr::checkout_span< T, Mode >::rend ( ) const
inlineconstexprnoexcept

◆ size()

template<typename T , typename Mode >
constexpr size_type ityr::checkout_span< T, Mode >::size ( ) const
inlineconstexprnoexcept

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