wpReleaseObjectMutexSem
This method is specific to Version 4, or higher, of the OS/2 operating system.
Each object has associated with it a mutex semaphore that can be used to serialize access to resources. This instance method is called to release the mutex semaphore for an object.
Syntax
_wpReleaseObjectMutexSem(somSelf)
Parameters
- somSelf (WPObject *) - input
- Pointer to the object on which the method is being invoked.
- Points to an object of class WPObject.
Returns
- rc (ULONG) - returns
- Return code from DosReleaseMutexSem.
Remarks
Each object has associated with it a mutex semaphore that can be used to serialize access to resources. This method is called to assert that the current thread indeed holds this mutex semaphore. Methods that expect to be invoked under semaphore protection can use this method to validate that the caller has indeed obtained ownership of the mutex semaphore.
This semaphore is used primarily to control access to the linked list of use items, but can be used for other purposes if needed. Folders also have a separate mutex semaphore, which is used to protect the content chain for that folder.
If you need both the object and the folder mutex semaphores, then you must obtain the folder mutex first.
If you need multiple object mutex semaphores, obtain them in object address order.
As with most semaphores, hold the semaphore for the minimum possible time.
Usage
You can call the wpReleaseObjectMutexSem method at any time to allow other methods to obtain access to a resource.
How to Override
This method is not generally overridden.
Example Code
In this example, you lock the folder pointed to by somSelf and enumerate all objects within the folder. When you are finished processing the objects in the folder, you unlock the folder.
WPObject *Object; BOOL bSem; bSem = !_wpRequestObjectMutexSem(somSelf,SEM_INDEFINITE_WAIT); for (Object = _wpQueryContent(somSelf,NULL,QC_FIRST); Object; Object = _wpQueryContent(somSelf,Object,QC_NEXT)); { /***** Process the returned object *****/ } if (bSem) { _wpReleaseObjectMutexSem(somSelf); }