IResourceLock

The IResourceLock class locks a resource for a specified period of time.

A simple yet effective use of this class is to declare a local object of this class that is in scope for the period of time that the resource needs to be locked. The lock is automatically removed when the block of code is exited, thereby forcing the object out of scope.

If the specified period of time is reached before the resource can be acquired, an IResourceExhausted exception is thrown.


IResourceLock - Member Functions and Data by Group

Constructors & Destructor

Use these members to construct and destruct objects of this class.


[view class]
~IResourceLock
public:
virtual ~IResourceLock()
Destroys the resource lock and releases the lock that was obtained by the constructor.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
IResourceLock
public:
IResourceLock(IResource& resource, long timeOut = - 1)
Constructs a resource lock object. The default and copy constructors are hidden. The only available constructor takes a resource to lock and an optional timeout value.
This is the only available constructor. You must provide the resource to be locked, and an optional timeout value.

resource
The IResource derived class that is to be locked.

timeOut
The number of milliseconds the caller is willing to wait to get the lock. If the lock cannot be gotten within this time, then an exception is thrown. It defaults to -1 which means to wait forever.

Exception

IOutOfSystemResource The request failed because of a lock time out. (DD) IAccessError Unexpected error while accessing underlying system object.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes

AIX Considerations

The AIX timer services used to implement the resource lock timeOut have a resolution of one second. The timeout values you provide are rounded up to the next one-second interval.


IResourceLock - Inherited Member Functions and Data

Inherited Public Functions

Inherited Public Data

Inherited Protected Functions

IResourceLock

Inherited Protected Data