☎️ rtchan
Realtime-safe channels (lock-free queues) for C++20
Loading...
Searching...
No Matches
rtchan::chan< T > Class Template Referenceabstract

Abstract common interface for all queues. More...

#include <rtchan.hpp>

Inheritance diagram for rtchan::chan< T >:
rtchan::mpmc< T, N > rtchan::mpsc< T, N > rtchan::spmc< T, N > rtchan::spsc< T, N >

Public Member Functions

virtual auto try_send (T &&item) noexcept -> bool=0
 Tries to send item over the channel, aborting if there is not enough room.
virtual auto try_send (span< const T > &&items) noexcept -> span< const T >=0
 Tries to send as many items in items over the channel as will fit.
virtual void send (T &&item) noexcept=0
 Sends item over the channel. If the channel is full, this function will block until space is available using a busy-wait loop.
virtual void send (span< const T > &&items) noexcept=0
 Sends all items in items over the channel. If the channel cannot fit all of items, this function will block until space is available using a busy-wait loop.
virtual auto try_recv (T &dest) noexcept -> bool=0
 Tries to receive an item from the channel, placing it into dest.
virtual auto try_recv (span< T > &dest) noexcept -> span< T >=0
 Tries to receive items up to the capacity of dest from the channel into dest.
virtual void recv (T &dest) noexcept=0
 Receives an item from the channel into dest. If the channel is empty, this function will block until an item is available using a busy-wait loop.
virtual void recv (span< T > &dest) noexcept=0
 Receives items equal to the capacity of dest from the channel into dest. If the channel does not have enough items to fill dest, this function will block until there are enough available items using a busy-wait loop.
virtual auto try_reserve_send (size_t count) noexcept -> span< T >=0
 Tries to reserve space for count items in the channel to be manually written into.
virtual auto reserve_send_up_to (size_t count) noexcept -> span< T >=0
 Tries to reserve space for up to count items in the channel to be manually written into.
virtual auto reserve_send (size_t count) noexcept -> span< T >=0
 Reserves space for count items in the channel to be manually written into. This function may spin until it can return a contiguous span of length count.
virtual auto try_commit_send (span< const T > &reservation) noexcept -> bool=0
 Tries to commit the items in reservation, indicating that they are finished being sent and are ready to be received. This function will fail until all previously obtained reservations to reservation have been committed.
virtual void commit_send (span< const T > &reservation) noexcept=0
 Commits the items in reservation, indicating that they are finished being sent and are ready to be received. This function may spin until all previously obtained reservations to reservation have been committed.
virtual auto try_reserve_recv (size_t count) noexcept -> span< T >=0
 Tries to reserve space for count items in the channel to be manually read from.
virtual auto reserve_recv_up_to (size_t count) noexcept -> span< T >=0
 Tries to reserve space for up to count items in the channel to be manually read from.
virtual auto reserve_recv (size_t count) noexcept -> span< T >=0
 Reserves space for count items in the channel to be manually read from.
virtual auto try_commit_recv (span< const T > &reservation) noexcept -> bool=0
 Tries to release the items in reservation, indicating that they are finished being received and are safe to be overwritten. This function may spin until all previously obtained reservations to reservation have been committed.
virtual void commit_recv (span< const T > &reservation) noexcept=0
 Releases the items in reservation, indicating that they are finished being received and are safe to be overwritten. This function may spin until all previously obtained reservations to reservation have been committed.

Detailed Description

template<typename T>
class rtchan::chan< T >

Abstract common interface for all queues.

Template Parameters
TThe type of item or message the queue holds
NThe capacity of the queue, must be a power of 2

Member Function Documentation

◆ commit_recv()

template<typename T>
virtual void rtchan::chan< T >::commit_recv ( span< const T > & reservation)
pure virtualnoexcept

Releases the items in reservation, indicating that they are finished being received and are safe to be overwritten. This function may spin until all previously obtained reservations to reservation have been committed.

Parameters
reservationThe reservation of items to mark as received

Implemented in rtchan::mpmc< T, N >.

◆ commit_send()

template<typename T>
virtual void rtchan::chan< T >::commit_send ( span< const T > & reservation)
pure virtualnoexcept

Commits the items in reservation, indicating that they are finished being sent and are ready to be received. This function may spin until all previously obtained reservations to reservation have been committed.

Parameters
reservationThe reservation of items to mark as sent

Implemented in rtchan::mpmc< T, N >.

◆ recv() [1/2]

template<typename T>
virtual void rtchan::chan< T >::recv ( span< T > & dest)
pure virtualnoexcept

Receives items equal to the capacity of dest from the channel into dest. If the channel does not have enough items to fill dest, this function will block until there are enough available items using a busy-wait loop.

Parameters
destThe destination to receive the items into

Implemented in rtchan::mpmc< T, N >.

◆ recv() [2/2]

template<typename T>
virtual void rtchan::chan< T >::recv ( T & dest)
pure virtualnoexcept

Receives an item from the channel into dest. If the channel is empty, this function will block until an item is available using a busy-wait loop.

Parameters
destThe destination to receive the item into

Implemented in rtchan::mpmc< T, N >.

◆ reserve_recv()

template<typename T>
virtual auto rtchan::chan< T >::reserve_recv ( size_t count) -> span< T >
pure virtualnoexcept

Reserves space for count items in the channel to be manually read from.

Parameters
countHow many items to try to reserve space for
Returns
A span containing the reserved space

Implemented in rtchan::mpmc< T, N >.

◆ reserve_recv_up_to()

template<typename T>
virtual auto rtchan::chan< T >::reserve_recv_up_to ( size_t count) -> span< T >
pure virtualnoexcept

Tries to reserve space for up to count items in the channel to be manually read from.

Parameters
countHow many items to try to reserve space for
Returns
A span containing what space was reserved, if any

Implemented in rtchan::mpmc< T, N >.

◆ reserve_send()

template<typename T>
virtual auto rtchan::chan< T >::reserve_send ( size_t count) -> span< T >
pure virtualnoexcept

Reserves space for count items in the channel to be manually written into. This function may spin until it can return a contiguous span of length count.

Parameters
countHow many items to try to reserve space for
Returns
A span containing the reserved space

Implemented in rtchan::mpmc< T, N >.

◆ reserve_send_up_to()

template<typename T>
virtual auto rtchan::chan< T >::reserve_send_up_to ( size_t count) -> span< T >
pure virtualnoexcept

Tries to reserve space for up to count items in the channel to be manually written into.

Parameters
countHow many items to try to reserve space for
Returns
A span containing what space was reserved, if any

Implemented in rtchan::mpmc< T, N >.

◆ send() [1/2]

template<typename T>
virtual void rtchan::chan< T >::send ( span< const T > && items)
pure virtualnoexcept

Sends all items in items over the channel. If the channel cannot fit all of items, this function will block until space is available using a busy-wait loop.

Parameters
itemsThe items to send

Implemented in rtchan::mpmc< T, N >.

◆ send() [2/2]

template<typename T>
virtual void rtchan::chan< T >::send ( T && item)
pure virtualnoexcept

Sends item over the channel. If the channel is full, this function will block until space is available using a busy-wait loop.

Parameters
itemThe item to send

Implemented in rtchan::mpmc< T, N >.

◆ try_commit_recv()

template<typename T>
virtual auto rtchan::chan< T >::try_commit_recv ( span< const T > & reservation) -> bool
pure virtualnoexcept

Tries to release the items in reservation, indicating that they are finished being received and are safe to be overwritten. This function may spin until all previously obtained reservations to reservation have been committed.

Parameters
reservationThe reservation of items to mark as received
Returns
Whether or not reservation was able to be committed or not.

Implemented in rtchan::mpmc< T, N >.

◆ try_commit_send()

template<typename T>
virtual auto rtchan::chan< T >::try_commit_send ( span< const T > & reservation) -> bool
pure virtualnoexcept

Tries to commit the items in reservation, indicating that they are finished being sent and are ready to be received. This function will fail until all previously obtained reservations to reservation have been committed.

Parameters
reservationThe reservation of items to mark as sent
Returns
Whether or not reservation was able to be committed or not.

Implemented in rtchan::mpmc< T, N >.

◆ try_recv() [1/2]

template<typename T>
virtual auto rtchan::chan< T >::try_recv ( span< T > & dest) -> span< T >
pure virtualnoexcept

Tries to receive items up to the capacity of dest from the channel into dest.

Parameters
destThe destination to receive the items into
Returns
The items succesfully received (a zero-length span indicates no items were received)

Implemented in rtchan::mpmc< T, N >.

◆ try_recv() [2/2]

template<typename T>
virtual auto rtchan::chan< T >::try_recv ( T & dest) -> bool
pure virtualnoexcept

Tries to receive an item from the channel, placing it into dest.

Parameters
destThe destination to receive the item into
Returns
Whether or not there was an item to be received

Implemented in rtchan::mpmc< T, N >.

◆ try_reserve_recv()

template<typename T>
virtual auto rtchan::chan< T >::try_reserve_recv ( size_t count) -> span< T >
pure virtualnoexcept

Tries to reserve space for count items in the channel to be manually read from.

Parameters
countHow many items to try to reserve space for
Returns
A span containing what space was reserved, with a zero-length span indicating failure

Implemented in rtchan::mpmc< T, N >.

◆ try_reserve_send()

template<typename T>
virtual auto rtchan::chan< T >::try_reserve_send ( size_t count) -> span< T >
pure virtualnoexcept

Tries to reserve space for count items in the channel to be manually written into.

Parameters
countHow many items to try to reserve space for
Returns
A span containing what space was reserved, with a zero-length span indicating failure

Implemented in rtchan::mpmc< T, N >.

◆ try_send() [1/2]

template<typename T>
virtual auto rtchan::chan< T >::try_send ( span< const T > && items) -> span< const T >
pure virtualnoexcept

Tries to send as many items in items over the channel as will fit.

Parameters
itemsThe items to try to send
Returns
What items were not sent, if any (a zero-length span indicates all items were sent)

Implemented in rtchan::mpmc< T, N >.

◆ try_send() [2/2]

template<typename T>
virtual auto rtchan::chan< T >::try_send ( T && item) -> bool
pure virtualnoexcept

Tries to send item over the channel, aborting if there is not enough room.

Parameters
itemThe item to try to send
Returns
Whether or not the item was sent

Implemented in rtchan::mpmc< T, N >.


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