Pipe.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/network/virtual_/Pipe.hpp"

Pipe

Virtual pipe implementation. Can be used for unidirectional data transfer between different threads of the same process.
Under the hood it uses oatpp::data::buffer::SynchronizedFIFOBuffer over the oatpp::data::buffer::IOBuffer.

namespace oatpp { namespace network { namespace virtual_ { 
  class Pipe : public oatpp::base::Countable {}
}}}

Methods

Return Type Name Summary
[none] Pipe Constructor.
std::shared_ptr<Pipe> createShared Create shared pipe.
Writer* getWriter Get pointer to Pipe::Writer for this pipe.
Reader* getReader Get pointer to Pipe::Reader for this pipe.
void close Mark pipe as closed.

Pipe::Pipe

Constructor.

Pipe()

Pipe::createShared

Create shared pipe.

  • @return - std::shared_ptr to Pipe.

static std::shared_ptr<Pipe> createShared()

Pipe::getWriter

Get pointer to Pipe::Writer for this pipe. There can be only one Pipe::Writer per pipe.

Writer* getWriter()

Pipe::getReader

Get pointer to Pipe::Reader for this pipe. There can be only one Pipe::Reader per pipe.

Reader* getReader()

Pipe::close

Mark pipe as closed.

void close()

Pipe::Reader

Pipe Reader. Extends oatpp::data::stream::InputStream. Provides read interface for the pipe. Can work in both blocking and nonblocking regime.

namespace oatpp { namespace network { namespace virtual_ { 
  class Pipe : public oatpp::base::Countable {
    class Reader : public oatpp::data::stream::InputStream {}
  };
}}}

Methods

Return Type Name Summary
void setNonBlocking Set true to make non-blocking reads using Pipe::Reader::read().
void setMaxAvailableToRead Limit the available amount of bytes to read from pipe.
data::v_io_size read Implements oatpp::data::stream::InputStream::read() method.

Pipe::Reader::setNonBlocking

Set true to make non-blocking reads using Pipe::Reader::read().

  • @param nonBlocking - true for nonblocking read.

void setNonBlocking(bool nonBlocking)

Pipe::Reader::setMaxAvailableToRead

Limit the available amount of bytes to read from pipe.
This method is used for testing purposes only.
set to -1 in order to ignore this value.

  • @param maxAvailableToRead - maximum available amount of bytes to read.

void setMaxAvailableToRead(data::v_io_size maxAvailableToRead)

Pipe::Reader::read

Implements oatpp::data::stream::InputStream::read() method. Read data from pipe.

  • @param data - buffer to read data to.
  • @param count - max count of bytes to read.
  • @return - oatpp::data::v_io_size.

data::v_io_size read(void *data, data::v_io_size count) override

Pipe::Writer

Pipe writer. Extends oatpp::data::stream::OutputStream. Provides write interface for the pipe. Can work in both blocking and nonblocking regime.

namespace oatpp { namespace network { namespace virtual_ { 
  class Pipe : public oatpp::base::Countable {
    class Writer : public oatpp::data::stream::OutputStream {}
  };
}}}

Methods

Return Type Name Summary
void setNonBlocking Set true to make non-blocking writes using Pipe::Writer::write().
void setMaxAvailableToWrite Limit the available space for data writes in pipe.
data::v_io_size write Implements oatpp::data::stream::OutputStream::write() method.

Pipe::Writer::setNonBlocking

Set true to make non-blocking writes using Pipe::Writer::write().

  • @param nonBlocking - true for nonblocking write.

void setNonBlocking(bool nonBlocking)

Pipe::Writer::setMaxAvailableToWrite

Limit the available space for data writes in pipe.
This method is used for testing purposes only.
set to -1 in order to ignore this value.

  • @param maxAvailableToWrite - maximum available amount of bytes to write.

void setMaxAvailableToWrite(data::v_io_size maxAvailableToWrite)

Pipe::Writer::write

Implements oatpp::data::stream::OutputStream::write() method. Write data to pipe.

data::v_io_size write(const void *data, data::v_io_size count) override