WvStreams
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
WvMagicCircle Class Reference

A circular queue that can be accessed across fork(). More...

#include <wvmagiccircle.h>

Inheritance diagram for WvMagicCircle:
Inheritance graph
[legend]

Public Member Functions

 WvMagicCircle (size_t size)
 Creates a shared memory circular queue. More...
 
size_t used ()
 
size_t left ()
 
size_t put (const void *data, size_t len)
 
size_t get (void *data, size_t len)
 
size_t skip (size_t len)
 
const char * wstype () const
 
virtual bool isok () const
 By default, returns true if geterr() == 0. More...
 
virtual int geterr () const
 If isok() is false, return the system error number corresponding to the error, -1 for a special error string (which you can obtain with errstr()) or 0 on end of file. More...
 
virtual WvString errstr () const
 
virtual void seterr (int _errnum)
 Set the errnum variable – we have an error. More...
 
void seterr (WvStringParm specialerr)
 
void seterr (WVSTRING_FORMAT_DECL)
 
void seterr (const WvErrorBase &err)
 
void seterr_both (int _errnum, WvStringParm specialerr)
 
void seterr_both (int _errnum, WVSTRING_FORMAT_DECL)
 
void noerr ()
 Reset our error state - there's no error condition anymore. More...
 

Static Public Member Functions

static WvString strerror (int errnum)
 A replacement for the operating system ::strerror() function that can map more kinds of error strings (especially in win32). More...
 

Protected Attributes

WvShmZone shm
 
volatile int & head
 
volatile int & tail
 
int size
 
char * circle
 
int errnum
 
WvString errstring
 

Detailed Description

A circular queue that can be accessed across fork().

Definition at line 14 of file wvmagiccircle.h.

Constructor & Destructor Documentation

◆ WvMagicCircle()

WvMagicCircle::WvMagicCircle ( size_t  size)

Creates a shared memory circular queue.

"size" is the number of elements to store

Definition at line 11 of file wvmagiccircle.cc.

References WvErrorBase::geterr(), and WvErrorBase::seterr().

◆ ~WvMagicCircle()

WvMagicCircle::~WvMagicCircle ( )

Definition at line 26 of file wvmagiccircle.cc.

Member Function Documentation

◆ used()

size_t WvMagicCircle::used ( )

Definition at line 32 of file wvmagiccircle.cc.

◆ left()

size_t WvMagicCircle::left ( )
inline

Definition at line 34 of file wvmagiccircle.h.

◆ put()

size_t WvMagicCircle::put ( const void *  data,
size_t  len 
)

Definition at line 44 of file wvmagiccircle.cc.

◆ get()

size_t WvMagicCircle::get ( void *  data,
size_t  len 
)

Definition at line 72 of file wvmagiccircle.cc.

◆ skip()

size_t WvMagicCircle::skip ( size_t  len)

Definition at line 94 of file wvmagiccircle.cc.

◆ wstype()

const char * WvMagicCircle::wstype ( ) const
inline

Definition at line 41 of file wvmagiccircle.h.

◆ isok()

virtual bool WvErrorBase::isok ( ) const
inlinevirtualinherited

By default, returns true if geterr() == 0.

Might be overridden so that isok() == false even though no error code has been specified.

Reimplemented in WvBufStream, WvDBusServer, WvDSAKey, WvEncoderStream, WvFdStream, WvIStreamList, WvListener, WvNullListener, WvLog, WvSSLStream, WvStream, WvStreamClone, WvTCPConn, WvTimeoutStream, WvTimeStream, WvReadLineStream, _WvConStream, and IWvStream.

Definition at line 39 of file wverror.h.

Referenced by WvListener::isok(), WvStream::isok(), and WvGlob::set().

◆ geterr()

virtual int WvErrorBase::geterr ( ) const
inlinevirtualinherited

If isok() is false, return the system error number corresponding to the error, -1 for a special error string (which you can obtain with errstr()) or 0 on end of file.

If isok() is true, returns an undefined number.

Reimplemented in WvDBusServer, and WvStreamClone.

Definition at line 48 of file wverror.h.

Referenced by UniIniGen::commit(), UniFileSystemGen::get(), WvDBusServer::geterr(), WvStreamClone::geterr(), WvEncoderStream::isok(), UniConfDaemon::listen(), WvStream::seterr(), and WvMagicCircle().

◆ errstr()

WvString WvErrorBase::errstr ( ) const
virtualinherited

Definition at line 127 of file wverror.cc.

◆ strerror()

WvString WvErrorBase::strerror ( int  errnum)
staticinherited

A replacement for the operating system ::strerror() function that can map more kinds of error strings (especially in win32).

Definition at line 91 of file wverror.cc.

References WvErrorBase::strerror().

Referenced by WvLog::perror(), WvErrorBase::strerror(), WvSSLStream::uread(), and WvSSLStream::uwrite().

◆ seterr() [1/4]

void WvErrorBase::seterr ( int  _errnum)
virtualinherited

Set the errnum variable – we have an error.

If called more than once, seterr() doesn't change the error code away from the previous one. That way, we remember the original cause of our problems.

Subclasses may want to override seterr(int) to shut themselves down (eg. WvStream::close()) when an error condition is set.

Note that seterr(WvString) will call seterr(-1).

Reimplemented in WvStream.

Definition at line 144 of file wverror.cc.

Referenced by WvTCPListener::accept(), WvUnixListener::accept(), WvDSAKey::getpem(), WvGlob::set(), WvStream::seterr(), WvMagicCircle(), WvPam::WvPam(), WvShmZone::WvShmZone(), and WvTCPListener::WvTCPListener().

◆ seterr() [2/4]

void WvErrorBase::seterr ( WvStringParm  specialerr)
inherited

Definition at line 159 of file wverror.cc.

◆ seterr() [3/4]

void WvErrorBase::seterr ( WVSTRING_FORMAT_DECL  )
inlineinherited

Definition at line 70 of file wverror.h.

◆ seterr() [4/4]

void WvErrorBase::seterr ( const WvErrorBase err)
inherited

Definition at line 170 of file wverror.cc.

◆ seterr_both() [1/2]

void WvErrorBase::seterr_both ( int  _errnum,
WvStringParm  specialerr 
)
inherited

Definition at line 179 of file wverror.cc.

◆ seterr_both() [2/2]

void WvErrorBase::seterr_both ( int  _errnum,
WVSTRING_FORMAT_DECL   
)
inlineinherited

Definition at line 73 of file wverror.h.

◆ noerr()

void WvErrorBase::noerr ( )
inlineinherited

Reset our error state - there's no error condition anymore.

Definition at line 78 of file wverror.h.

Member Data Documentation

◆ shm

WvShmZone WvMagicCircle::shm
protected

Definition at line 26 of file wvmagiccircle.h.

◆ head

volatile int& WvMagicCircle::head
protected

Definition at line 28 of file wvmagiccircle.h.

◆ tail

volatile int & WvMagicCircle::tail
protected

Definition at line 28 of file wvmagiccircle.h.

◆ size

int WvMagicCircle::size
protected

Definition at line 29 of file wvmagiccircle.h.

◆ circle

char* WvMagicCircle::circle
protected

Definition at line 30 of file wvmagiccircle.h.

◆ errnum

int WvErrorBase::errnum
protectedinherited

Definition at line 26 of file wverror.h.

◆ errstring

WvString WvErrorBase::errstring
protectedinherited

Definition at line 27 of file wverror.h.


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