IResource
- The IResource class is the abstract base resource class. Use a derived class to identify a serially reusable resource.
The concept of resource is similar to the common definition of mutex and monitor. These resources can be limited to the
current process, as described by the IPrivateResource class,
or they can be shared across multiple processes, as described by ISharedResource class.
IResource - Member Functions and Data by Group
Constructors & Destructor
You cannot construct or destruct objects of this class. Derive a new class from this class to identify a serially reusable
resource if the derived Open Class Library classes do not meet your needs.
- ~IResource
public:
virtual ~IResource()
- Destroys the resource, releasing it is if it is currently locked.
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
- IResource
public:
IResource()
- Constructs a resource object. This is only available to derived classes.
- The default constructor.
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
Resource Locking
Use resource-locking members to acquire or release a serialized access to this resource.
- lock
public:
virtual IResource& lock(long timeOut = - 1) = 0
- Acquires serialized access to the resource, preventing other threads of execution from accessing it.
You can specify the value for timeout in milliseconds with -1 indicating an indefinite wait
and 0 requesting an immediate return.
Locks can be be obtained multiple times on the same resource by the same thread. A corresponding
number of unlocks must be performed to release the resource.
- timeout
- The number of milliseconds the caller is willing to wait to get the lock. If the lock cannot be gotten
within that time period, then an exception is thrown.
- 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 X timer services used to implement the resource lock timeout have a resolution
of one second. The lock function rounds up the specified timeout value to the
next one-second interval.
- unlock
public:
virtual IResource& unlock() = 0
- Releases access to the resource, allowing other threads of execution to access it. If multiple locks have
been done by the same thread, this only bumps down the lock count. Once the lock count reaches zero
again, the resource will be released.
- Exception
| IAccessError
| Unexpected error while accessing underlying system object.
|
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
- relockAll
protected:
void relockAll(long times)
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
- unlockAll
protected:
long unlockAll()
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
IResource - Inherited Member Functions and Data
Inherited Public Functions
Inherited Public Data
Inherited Protected Functions
Inherited Protected Data