CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Pipe< pipeType > Class Template Reference

#include <pipe.h>

Inheritance diagram for Pipe< pipeType >:
Collaboration diagram for Pipe< pipeType >:

Public Member Functions

 Pipe ()
 
 ~Pipe ()
 
void Close ()
 
void CloseReadFd ()
 
void CloseWriteFd ()
 
template<typename T >
bool TryWrite (const T &data)
 
template<typename T >
bool Write (const T &data)
 
bool Write (const void *buf, size_t nbyte)
 
template<typename T >
bool TryRead (T *data)
 
template<typename T >
bool Read (T *data)
 
bool Read (void *buf, size_t nbyte)
 
int GetReadFd () const
 
int GetWriteFd () const
 

Private Member Functions

 FRIEND_TEST (T_Util, ManagedExecRunShell)
 
 FRIEND_TEST (T_Util, ManagedExecExecuteBinaryDoubleFork)
 
 FRIEND_TEST (T_Util, ManagedExecExecuteBinaryAsChild)
 
 Pipe (const int fd_read, const int fd_write)
 
void MakePipe (int pipe_fd[2])
 
void WritePipe (int fd, const void *buf, size_t nbyte)
 
void ReadPipe (int fd, void *buf, size_t nbyte)
 

Private Attributes

int fd_read_
 
int fd_write_
 

Additional Inherited Members

- Protected Member Functions inherited from SingleCopy
 SingleCopy ()
 

Detailed Description

template<PipeType pipeType>
class Pipe< pipeType >

Definition at line 45 of file pipe.h.

Constructor & Destructor Documentation

template<PipeType pipeType>
Pipe< pipeType >::Pipe ( )
inline

A pipe is a simple asynchronous communication mechanism. It establishes a unidirectional communication link between two file descriptors. One of them is used to only write to the pipe, the other one only to read from it.

This class is a simple wrapper around the handling of a "standard" pipe that uses system calls.

Note
PipeType as class template parameter should symbolize the functionality of the specific type, independent of what variable name it has

Definition at line 63 of file pipe.h.

template<PipeType pipeType>
Pipe< pipeType >::~Pipe ( )
inline

Destructor closes all valid file descriptors of the pipe

Definition at line 73 of file pipe.h.

template<PipeType pipeType>
Pipe< pipeType >::Pipe ( const int  fd_read,
const int  fd_write 
)
inlineprivate

Only used in the unit tests to test pipes using stdin/stdout as read/write.

Definition at line 205 of file pipe.h.

Member Function Documentation

template<PipeType pipeType>
void Pipe< pipeType >::Close ( )
inline

Closes all open file descriptors of the pipe and marks them as invalid

Definition at line 80 of file pipe.h.

template<PipeType pipeType>
void Pipe< pipeType >::CloseReadFd ( )
inline

Closes file descriptor that reads from the pipe and marks it as invalid.

Definition at line 88 of file pipe.h.

Referenced by Watchdog::Fork().

Here is the caller graph for this function:

template<PipeType pipeType>
void Pipe< pipeType >::CloseWriteFd ( )
inline

Closes file descriptor that writes to the pipe and marks it as invalid.

Definition at line 98 of file pipe.h.

Referenced by Watchdog::Fork().

Here is the caller graph for this function:

template<PipeType pipeType>
Pipe< pipeType >::FRIEND_TEST ( T_Util  ,
ManagedExecRunShell   
)
private
template<PipeType pipeType>
Pipe< pipeType >::FRIEND_TEST ( T_Util  ,
ManagedExecExecuteBinaryDoubleFork   
)
private
template<PipeType pipeType>
Pipe< pipeType >::FRIEND_TEST ( T_Util  ,
ManagedExecExecuteBinaryAsChild   
)
private
template<PipeType pipeType>
int Pipe< pipeType >::GetReadFd ( ) const
inline

Returns the file descriptor that reads from the pipe

Definition at line 186 of file pipe.h.

template<PipeType pipeType>
int Pipe< pipeType >::GetWriteFd ( ) const
inline

Returns the file descriptor that writes to the pipe

Definition at line 193 of file pipe.h.

Referenced by Watchdog::Fork().

Here is the caller graph for this function:

template<PipeType pipeType>
void Pipe< pipeType >::MakePipe ( int  pipe_fd[2])
inlineprivate

Creating a pipe should always succeed.

Definition at line 211 of file pipe.h.

template<PipeType pipeType>
template<typename T >
bool Pipe< pipeType >::Read ( T *  data)
inline

Reads an object from the pipe

Returns
true on success otherwise kills the program with an assert

Definition at line 166 of file pipe.h.

Referenced by download::DownloadManager::Fetch(), and Watchdog::Fork().

Here is the caller graph for this function:

template<PipeType pipeType>
bool Pipe< pipeType >::Read ( void *  buf,
size_t  nbyte 
)
inline

Reads an object from the pipe If possible, it is recommend to use "bool Read(T *data)""

Returns
true on success otherwise kills the program with an assert

Definition at line 178 of file pipe.h.

template<PipeType pipeType>
void Pipe< pipeType >::ReadPipe ( int  fd,
void *  buf,
size_t  nbyte 
)
inlineprivate

Reads from a pipe should always succeed.

Definition at line 239 of file pipe.h.

template<PipeType pipeType>
template<typename T >
bool Pipe< pipeType >::TryRead ( T *  data)
inline

(Re)tries to read from the pipe until it receives data or returned error is NOT a system interrupt

Returns
true if sizeof(data) bytes were received false otherwise

Definition at line 151 of file pipe.h.

template<PipeType pipeType>
template<typename T >
bool Pipe< pipeType >::TryWrite ( const T &  data)
inline

Tries to write an object to the pipe

Returns
true if the entire object was written false otherwise

Definition at line 112 of file pipe.h.

template<PipeType pipeType>
template<typename T >
bool Pipe< pipeType >::Write ( const T &  data)
inline

Writes an object to the pipe

Returns
true on success otherwise kills the program with an assert

Definition at line 125 of file pipe.h.

Referenced by Watchdog::Fork().

Here is the caller graph for this function:

template<PipeType pipeType>
bool Pipe< pipeType >::Write ( const void *  buf,
size_t  nbyte 
)
inline

Writes an object to the pipe If possible, it is recommended to use "bool Write(const T &data)"

Returns
true on success otherwise kills the program with an assert

Definition at line 138 of file pipe.h.

template<PipeType pipeType>
void Pipe< pipeType >::WritePipe ( int  fd,
const void *  buf,
size_t  nbyte 
)
inlineprivate

Writes to a pipe should always succeed.

Definition at line 222 of file pipe.h.

Member Data Documentation

template<PipeType pipeType>
int Pipe< pipeType >::fd_read_
private

Definition at line 199 of file pipe.h.

template<PipeType pipeType>
int Pipe< pipeType >::fd_write_
private

Definition at line 200 of file pipe.h.


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