Jump to content

wpAssertObjectMutexSem

From EDM2

This method is specific to Version 4, or higher, of the OS/2 operating system.

This instance method verifies that an object's mutex semaphore is held for the current thread.

Syntax

_wpAssertObjectMutexSem(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 (BOOL) - returns
Success indicator.
TRUE: The object semaphore is held by the calling thread.
FALSE: The object semaphore is not held by the calling thread.

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 it can be used for other purposes, if needed. Folders also have a separate mutex semaphore that 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

This method is called to test whether some other method has requested serialization of access to this object. For example, you might define a method that requires the caller to obtain the object's mutex semaphore before calling your method. You can use the wpAssertObjectMutexSem method to insure that the caller has properly serialized the object before calling your method.

How to Override

This method is generally not overridden.

Example Code

BOOL bIsLocked;

bIsLocked = _wpAssertObjectMutexSem(self);
if (!bIsLocked)
{
return FALSE;
}

Related Methods