Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PhosphorChannel::RingReader Class Reference

#include <PhosphorChannel/Ring.h>

Public Member Functions

 ~RingReader ()
 RingReader (const RingReader &)=delete
RingReader & operator= (const RingReader &)=delete
ReadResult read (std::string &frame)
 The next frame in frame, without waiting.
const std::string & codec () const
std::size_t capacity () const
int dataFd () const
 Readable when the writer wrote after a read() returned Empty, closed the ring, or went away.
void clearDataSignal ()
void close ()
 Tells the writer that nothing reads any more: its writes return Closed.

Static Public Member Functions

static std::unique_ptr< RingReader > attach (int memoryFd, int wakeFd, std::string codec, std::size_t maxCapacity, std::string *error)
 Maps the ring of a writer.

Constructor & Destructor Documentation

◆ ~RingReader()

PhosphorChannel::RingReader::~RingReader ( )

◆ RingReader()

PhosphorChannel::RingReader::RingReader ( const RingReader & )
delete

Member Function Documentation

◆ attach()

std::unique_ptr< RingReader > PhosphorChannel::RingReader::attach ( int memoryFd,
int wakeFd,
std::string codec,
std::size_t maxCapacity,
std::string * error )
static

Maps the ring of a writer.

Takes both fds, also on a failure. Refuses a memfd that is not plain shared memory, lacks the size seals, is larger than maxCapacity, or does not match its header, and a wake fd that is not a Unix stream socket. codec is what the handshake said.

◆ capacity()

std::size_t PhosphorChannel::RingReader::capacity ( ) const
inline

◆ clearDataSignal()

void PhosphorChannel::RingReader::clearDataSignal ( )

◆ close()

void PhosphorChannel::RingReader::close ( )

Tells the writer that nothing reads any more: its writes return Closed.

Later reads return Closed too.

◆ codec()

const std::string & PhosphorChannel::RingReader::codec ( ) const
inline

◆ dataFd()

int PhosphorChannel::RingReader::dataFd ( ) const
inline

Readable when the writer wrote after a read() returned Empty, closed the ring, or went away.

Only Empty asks the writer for a signal: a reader that stops before Empty while frames wait gets no signal for them, so it reads until Empty before it waits. Call clearDataSignal() before the reads that drain the ring.

◆ operator=()

RingReader & PhosphorChannel::RingReader::operator= ( const RingReader & )
delete

◆ read()

ReadResult PhosphorChannel::RingReader::read ( std::string & frame)

The next frame in frame, without waiting.

Closed once the writer closed the ring, or this end saw it go away (see dataFd()), and every frame was read, and after close().


The documentation for this class was generated from the following file:
  • phosphor-channel/include/PhosphorChannel/Ring.h