Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Examples

Pipe Class Reference

The Pipe uses system kernel buffering to hold data being passed either between two execution contexts within the same process, or between different processes. kernel buffering between processes and/or threads. More...

#include <file.h>

List of all members.

Public Member Functions

bool operator! ()
 Used to see if the pipe has any open entities.

int receive (void *addr)
 Perform an object atomic transfer of data from a pipe.

int send (void *addr)
 Perform an object atomic transfer of data to a pipe.

bool isValid (void)
 Verify this object is "valid".


Protected Member Functions

int getSize (void)
 Get the object size for atomic operations.

void endSender (void)
 Sender is often used for implementing a fork()'d message port between processes.

void endReceiver (void)
 Receiver is often used for implementing a fork()'d message port between processes.

 Pipe (int size=512, int count=1)
 Create a kernel pipe descriptor set using pipe().

virtual ~Pipe ()
 Destroy the pipe and kernel descriptor resources.

 Pipe (const Pipe &orig)
 Create a pipe as a duplicate of an existing pipe.

Pipeoperator= (const Pipe &orig)
void sender (void)
void receiver (void)
int read (void *buf, int len)
int write (void *buf, int len)

Protected Attributes

int fd [2]
int objcount
int objsize


Detailed Description

The Pipe uses system kernel buffering to hold data being passed either between two execution contexts within the same process, or between different processes. kernel buffering between processes and/or threads.

Unlike thread's "Buffer", Pipe uses system descriptors and kernel memory. Under Posix, the size of the pipe and associated kernel memory is always a fixed constant as defined by _PC_PIPE_BUF. The Common C++ "pipe" class primarily deals with "atomic" transfers of fixed sized objects through pipes. Pipes may pass data arbitrarily and can also be used through the "pipestream" class.

The "Pipe" class is not meant to be a true "public" class, but as a builder class for deriving other classes.

Author:
David Sugar <dyfet@ostel.com>


Constructor & Destructor Documentation

Pipe::Pipe int  size = 512,
int  count = 1
[protected]
 

Create a kernel pipe descriptor set using pipe().

On systems which allow the pipe kernel buffer to be defined, a size for aligned atomic transfers can be set, as well as the number of atomic objects the kernel will buffer. On Posix systems, these options are ignored.

Parameters:
size objsize of atomic objects to send.
count count of atomic objects to kernel buffer.

virtual Pipe::~Pipe  )  [protected, virtual]
 

Destroy the pipe and kernel descriptor resources.

Pipe::Pipe const Pipe orig  )  [protected]
 

Create a pipe as a duplicate of an existing pipe.

Parameters:
orig pipe to duplicate.


Member Function Documentation

void Pipe::endReceiver void   )  [inline, protected]
 

Receiver is often used for implementing a fork()'d message port between processes.

By stopping the receiver, the current pipe can then only be used for sending, and the receiver is presumed to be in the other half of a fork()'d process.

See also:
endSender

void Pipe::endSender void   )  [inline, protected]
 

Sender is often used for implementing a fork()'d message port between processes.

By stopping the sender, the current pipe can then only be used for receiving, and the sender is presumed to be in the other half of a fork()'d process.

See also:
endReceiver

int Pipe::getSize void   )  [inline, protected]
 

Get the object size for atomic operations.

Returns:
size of atomic operations.

bool Pipe::isValid void   ) 
 

Verify this object is "valid".

Returns:
true if valid.

bool Pipe::operator!  ) 
 

Used to see if the pipe has any open entities.

Pipe& Pipe::operator= const Pipe orig  )  [protected]
 

int Pipe::read void *  buf,
int  len
[inline, protected]
 

int Pipe::receive void *  addr  )  [inline]
 

Perform an object atomic transfer of data from a pipe.

Returns:
number of bytes actually read if successful.
Parameters:
addr pointer to store read data.

void Pipe::receiver void   )  [inline, protected]
 

int Pipe::send void *  addr  )  [inline]
 

Perform an object atomic transfer of data to a pipe.

Returns:
number of bytes written if successful.
Parameters:
addr pointer to write data from.

void Pipe::sender void   )  [inline, protected]
 

int Pipe::write void *  buf,
int  len
[inline, protected]
 


Member Data Documentation

int Pipe::fd[2] [protected]
 

int Pipe::objcount [protected]
 

int Pipe::objsize [protected]
 


The documentation for this class was generated from the following file:
Generated on Thu Sep 25 13:14:32 2003 for GNU CommonC++ by doxygen 1.3.3