tetengo 1.8.1
A multipurpose library set
Loading...
Searching...
No Matches
tetengo::json::channel Class Reference

A channel. More...

#include <channel.hpp>

+ Inheritance diagram for tetengo::json::channel:
+ Collaboration diagram for tetengo::json::channel:

Public Member Functions

 channel (std::size_t capacity)
 Creates a channel.
 
 ~channel ()
 Destroys the JSON parser.
 
void insert (element element_)
 Inserts an element.
 
void insert (std::exception_ptr &&p_exception)
 Inserts an exception.
 
const elementpeek () const
 Returns the front element.
 
void take ()
 Takes an element.
 
bool closed () const
 Returns true the channel is closed.
 
void close ()
 Closes the channel.
 

Detailed Description

A channel.

Constructor & Destructor Documentation

◆ channel()

tetengo::json::channel::channel ( std::size_t  capacity)
explicit

Creates a channel.

Parameters
capacityA capacity. Must be greater than 0.
Exceptions
std::invalid_argumentWhen capacity is 0.

Member Function Documentation

◆ closed()

bool tetengo::json::channel::closed ( ) const

Returns true the channel is closed.

Return values
trueWhen the channel is closed.
falseOtherwise.

◆ insert() [1/2]

void tetengo::json::channel::insert ( element  element_)

Inserts an element.

The element inserted after a close() call are just discarded.

Parameters
element_An element.

◆ insert() [2/2]

void tetengo::json::channel::insert ( std::exception_ptr &&  p_exception)

Inserts an exception.

The exception inserted after a close() call are just discarded.

Parameters
p_exceptionAn exception pointer.

◆ peek()

const element & tetengo::json::channel::peek ( ) const

Returns the front element.

Returns
The front element.
Exceptions
unspecifiedAn exception inserted with insert(std::exception_ptr&&).
std::logic_errorWhen the channel is already closed.

◆ take()

void tetengo::json::channel::take ( )

Takes an element.

Exceptions
std::logic_errorWhen the channel is already closed.

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