Socket Class Reference

A simple socket-holder class to make sure that socket fd's added to Messages get properly closed and not leaked if said Messages never get processed. More...

#include <Socket.h>

Inheritance diagram for Socket:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 Socket ()
 Default constructor.
 Socket (int fd, bool okayToClose=true)
 Constructor.
virtual ~Socket ()
 Destructor.
int ReleaseFileDescriptor ()
 Returns and releases our held file descriptor.
int GetFileDescriptor () const
 Returns the held socket fd, but does not release ownership of it.
void SetFileDescriptor (int fd, bool okayToClose=true)
 Sets our file descriptor.
void IncrementRefCount () const
 Increments the counter and returns true iff the new value is zero.
bool DecrementRefCount () const
 Decrements the counter and returns true iff the new value is zero.
void SetManager (AbstractObjectManager *manager)
 Sets the recycle-pointer for this object.
AbstractObjectManagerGetManager () const
 Returns this object's current recyler pointer.
uint32 GetRefCount () const
 Returns this object's current reference count.

Detailed Description

A simple socket-holder class to make sure that socket fd's added to Messages get properly closed and not leaked if said Messages never get processed.

Definition at line 14 of file Socket.h.


Constructor & Destructor Documentation

Socket::Socket ( int  fd,
bool  okayToClose = true 
) [inline, explicit]

Constructor.

Parameters:
fd File descriptor of a socket. (fd) becomes property of this Socket object.
okayToClose If true (fd) will be closed by the destructor. If false, we will not close (fd). Defaults to true.

Definition at line 25 of file Socket.h.

virtual Socket::~Socket (  )  [virtual]

Destructor.

Closes our held file descriptor, if we have one.


Member Function Documentation

int Socket::ReleaseFileDescriptor (  )  [inline]

Returns and releases our held file descriptor.

When this method returns, ownership of the socket is transferred to the calling code.

Definition at line 33 of file Socket.h.

void Socket::SetFileDescriptor ( int  fd,
bool  okayToClose = true 
)

Sets our file descriptor.

Will close any old one if appropriate.

void RefCountable::IncrementRefCount (  )  const [inline, inherited]

Increments the counter and returns true iff the new value is zero.

Thread safe.

Definition at line 32 of file RefCount.h.

References AtomicCounter::AtomicIncrement().

bool RefCountable::DecrementRefCount (  )  const [inline, inherited]

Decrements the counter and returns true iff the new value is zero.

Thread safe.

Definition at line 35 of file RefCount.h.

References AtomicCounter::AtomicDecrement().

void RefCountable::SetManager ( AbstractObjectManager manager  )  [inline, inherited]

Sets the recycle-pointer for this object.

If set to non-NULL, this pointer is used by the ObjectPool class to recycle this object when it is no longer in use, so as to avoid the overhead of having to delete it and re-create it later on. The RefCountable class itself does nothing with this pointer. Default value is NULL.

Parameters:
manager Pointer to the new manager object to use, or NULL to use no manager.

Definition at line 44 of file RefCount.h.

uint32 RefCountable::GetRefCount (  )  const [inline, inherited]

Returns this object's current reference count.

Note that the value returned by this method is volatile in multithreaded environments, so it may already be wrong by the time it is returned. Be careful!

Definition at line 54 of file RefCount.h.

References AtomicCounter::GetCount().


The documentation for this class was generated from the following file:
Generated on Thu Jun 5 17:48:34 2008 for MUSCLE by  doxygen 1.5.1