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

#include <PhosphorChannel/Ring.h>

Public Member Functions

 ~RingWriter ()
 RingWriter (const RingWriter &)=delete
RingWriter & operator= (const RingWriter &)=delete
WriteResult tryWrite (std::string_view frame)
 Writes one frame without waiting.
WriteResult write (std::string_view frame, int timeoutMs)
 Waits up to timeoutMs (-1: no limit) for space.
std::size_t maxFrame () const
 The largest frame that the ring takes.
std::size_t capacity () const
const std::string & codec () const
int spaceFd () const
 Readable when the reader freed the space that a WouldBlock asked for, closed the ring, or went away.
void clearSpaceSignal ()
void close ()
 Tells the reader that no frame follows.
int memoryFd () const
 The memfd of the ring.

Static Public Member Functions

static std::unique_ptr< RingWriter > create (std::size_t capacity, std::string codec, std::string *error)
 A ring of capacity bytes (rounded up to 8) for codec.

Static Public Attributes

static constexpr std::size_t MinCapacity = 4096
 The smallest and the largest data area, in bytes.
static constexpr std::size_t MaxCapacity = std::size_t(1) << 30

Constructor & Destructor Documentation

◆ ~RingWriter()

PhosphorChannel::RingWriter::~RingWriter ( )

◆ RingWriter()

PhosphorChannel::RingWriter::RingWriter ( const RingWriter & )
delete

Member Function Documentation

◆ capacity()

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

◆ clearSpaceSignal()

void PhosphorChannel::RingWriter::clearSpaceSignal ( )

◆ close()

void PhosphorChannel::RingWriter::close ( )

Tells the reader that no frame follows.

Frames written before still reach it.

◆ codec()

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

◆ create()

std::unique_ptr< RingWriter > PhosphorChannel::RingWriter::create ( std::size_t capacity,
std::string codec,
std::string * error )
static

A ring of capacity bytes (rounded up to 8) for codec.

Nullptr with error for a bad codec or capacity, or a failed memfd.

◆ maxFrame()

std::size_t PhosphorChannel::RingWriter::maxFrame ( ) const

The largest frame that the ring takes.

◆ memoryFd()

int PhosphorChannel::RingWriter::memoryFd ( ) const
inline

The memfd of the ring.

The ring owns it: never close it. A mapping of a dup() of it sees the ring, which the tests use to break the layout.

◆ operator=()

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

◆ spaceFd()

int PhosphorChannel::RingWriter::spaceFd ( ) const
inline

Readable when the reader freed the space that a WouldBlock asked for, closed the ring, or went away.

Call clearSpaceSignal() before the tryWrite() that it wakes: a signal cleared after that retry can be the one that its WouldBlock asked for, and then nothing wakes the writer.

◆ tryWrite()

WriteResult PhosphorChannel::RingWriter::tryWrite ( std::string_view frame)

Writes one frame without waiting.

Closed once the reader closed the ring, or once this end saw it go away (see spaceFd()).

◆ write()

WriteResult PhosphorChannel::RingWriter::write ( std::string_view frame,
int timeoutMs )

Waits up to timeoutMs (-1: no limit) for space.

WouldBlock after the timeout. A reader that exits ends the wait with Closed.

Member Data Documentation

◆ MaxCapacity

std::size_t PhosphorChannel::RingWriter::MaxCapacity = std::size_t(1) << 30
staticconstexpr

◆ MinCapacity

std::size_t PhosphorChannel::RingWriter::MinCapacity = 4096
staticconstexpr

The smallest and the largest data area, in bytes.


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