Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Resource Class Reference

Inheritance diagram for Resource:

IResource Conduit Socket FileConduit DatagramSocket ServerSocket SocketConduit MulticastSocket List of all members.

Public Member Functions

protected void closure ()
 this ()
 ~this ()
Object getLock ()
void setLock (Object lock)
void acquire ()
bool acquireIfOpen ()
void close ()

Protected Attributes

Object _lock

Private Attributes

int usage

Detailed Description

Protocol for acquiring and releasing a resource such as a file, or socket. This isn't strictly necessary, but will aid migration to a multi-threaded runtime environment.

Definition at line 49 of file Resource.d.


Constructor & Destructor Documentation

~this  )  [inline]
 

Make a reasonable attempt to clean up

Definition at line 85 of file Resource.d.

References close(), and version.


Member Function Documentation

protected void closure  ) 
 

Subclasses must implement closure mechanics. This is invoked when the number of close() invocations match that of aquire() -- the latter is typically called immediately following the successful construction of an IResource implementation; one should expect close to be required at least once.

Reimplemented from IResource.

Reimplemented in Conduit, FileConduit, and Socket.

Referenced by close().

this  )  [inline]
 

Set the default lock to be this object

Reimplemented in DatagramSocket, and SocketConduit.

Definition at line 74 of file Resource.d.

References _lock.

Object getLock  )  [inline]
 

Return the lock used by this resource

Reimplemented from IResource.

Definition at line 101 of file Resource.d.

References _lock.

void setLock Object  lock  )  [inline]
 

Set an alternate lock. Typically one would use this to synchronize multiple different Resource via a common object.

Reimplemented from IResource.

Definition at line 115 of file Resource.d.

void acquire  )  [inline]
 

hold a reference to this resource. The caller is now responsible for invoking close() upon this resource;

Reimplemented from IResource.

Definition at line 130 of file Resource.d.

References _lock, and usage.

Referenced by Socket::set(), Socket::this(), and FileConduit::this().

bool acquireIfOpen  )  [inline]
 

If this resource is still open, acquire it and return true. This is a threadsafe test-and-set mechanism that fails only if the resource is already closed, or was never opened.

Note that you are responsible for invoking close() whenever this method returns true.

Reimplemented from IResource.

Definition at line 149 of file Resource.d.

References _lock, and usage.

void close  )  [inline]
 

release a reference to this resource

Reimplemented from IResource.

Definition at line 168 of file Resource.d.

References _lock, closure(), and usage.

Referenced by ~this(), and FileConduit::VersionWin32::Win32MappedBuffer::~this().


Member Data Documentation

Object _lock [protected]
 

Definition at line 51 of file Resource.d.

Referenced by acquire(), acquireIfOpen(), close(), getLock(), and this().

int usage [private]
 

Definition at line 52 of file Resource.d.

Referenced by acquire(), acquireIfOpen(), and close().


The documentation for this class was generated from the following file:
Generated on Sun Nov 7 19:07:09 2004 for Mango by doxygen 1.3.6