Original Symbian headers
Selected EUSER, Window Server, networking, graphics and device declarations
Loading...
Searching...
No Matches
RMutex Class Reference

A handle to a mutex. More...

#include <e32std.h>

Inheritance diagram for RMutex:
RHandleBase

Public Member Functions

TInt Open (const TFindMutex &aFind, TOwnerType aType=EOwnerProcess)
 Opens a handle to the global mutex found using a TFindMutex object.
 
IMPORT_C TInt CreateLocal (TOwnerType aType=EOwnerProcess)
 Creates a mutex and opens this handle to the mutex.
 
IMPORT_C TInt CreateGlobal (const TDesC &aName, TOwnerType aType=EOwnerProcess)
 Creates a global mutex and opens this handle to the mutex.
 
IMPORT_C TInt OpenGlobal (const TDesC &aName, TOwnerType aType=EOwnerProcess)
 Opens a handle to a global mutex.
 
IMPORT_C TInt Open (RMessagePtr2 aMessage, TInt aParam, TOwnerType aType=EOwnerProcess)
 Opens a handle to a mutex using a handle number sent by a client to a server.
 
IMPORT_C TInt Open (TInt aArgumentIndex, TOwnerType aType=EOwnerProcess)
 Opens a handle to a mutex using a handle number passed as an environment data item to the child process during the creation of that child process.
 
IMPORT_C void Wait ()
 Acquire the mutex, waiting for it to become free if necessary.
 
IMPORT_C TInt Poll ()
 
IMPORT_C TInt Wait (TInt aTimeout)
 
IMPORT_C void Signal ()
 Release the mutex.
 
IMPORT_C TBool IsHeld ()
 Test if this mutex is held by the current thread.
 
- Public Member Functions inherited from RHandleBase
 RHandleBase ()
 Default constructor.
 
TInt Handle () const
 Retrieves the handle-number of the object associated with this handle.
 
void SetHandle (TInt aHandle)
 Sets the handle-number of this handle to the specified value.
 
TInt SetReturnedHandle (TInt aHandleOrError)
 Sets the handle-number of this handle to the specified value.
 
IMPORT_C void Close ()
 Closes the handle.
 
IMPORT_C TName Name () const
 Gets the name of the handle.
 
IMPORT_C TFullName FullName () const
 Gets the full name of the handle.
 
IMPORT_C void FullName (TDes &aName) const
 Gets the full name of the handle.
 
IMPORT_C void SetHandleNC (TInt aHandle)
 Sets the handle-number of this handle to the specified value, and marks it as not closable.
 
IMPORT_C TInt Duplicate (const RThread &aSrc, TOwnerType aType=EOwnerProcess)
 Creates a valid handle to the kernel object for which the specified thread already has a handle.
 
IMPORT_C void HandleInfo (THandleInfo *anInfo)
 Gets information about the handle.
 
IMPORT_C TUint Attributes () const
 
IMPORT_C TInt BTraceId () const
 Returns a unique object identifier for use with BTrace.
 
IMPORT_C void NotifyDestruction (TRequestStatus &aStatus)
 Internal technology API.
 

Additional Inherited Members

- Public Types inherited from RHandleBase
enum  TAttributes { EReadAccess =0x1 , EWriteAccess =0x2 , EDirectReadAccess =0x4 , EDirectWriteAccess =0x8 }
 Read/Write attributes for the handle. More...
 
- Static Public Member Functions inherited from RHandleBase
static void DoExtendedClose ()
 
- Protected Member Functions inherited from RHandleBase
 RHandleBase (TInt aHandle)
 Copy constructor.
 
IMPORT_C TInt Open (const TFindHandleBase &aHandle, TOwnerType aType)
 Opens a handle to a kernel side object found using a find-handle object.
 
TInt OpenByName (const TDesC &aName, TOwnerType aOwnerType, TInt aObjectType)
 Implementation for RXxxxx::Open/OpenGlocbal(const TDesC &aName,,TOwnerType aType) functions.
 
- Static Protected Member Functions inherited from RHandleBase
static TInt SetReturnedHandle (TInt aHandleOrError, RHandleBase &aHandle)
 
- Protected Attributes inherited from RHandleBase
TInt iHandle
 

Detailed Description

A handle to a mutex.

The mutex itself is a kernel side object.

Handles should be closed after use. RHandleBase provides the necessary Close() function which should be called when the handle is no longer required.

See also
RHandleBase::Close
API status
Published to all clients. Released API.

Definition at line 3501 of file e32std.h.

Member Function Documentation

◆ CreateGlobal()

IMPORT_C TInt RMutex::CreateGlobal ( const TDesC &  aName,
TOwnerType  aType = EOwnerProcess 
)

Creates a global mutex and opens this handle to the mutex.

The kernel side object representing the mutex is given the name contained in the specified descriptor, which makes it global. This means that any thread in any process can search for the mutex, using TFindMutex, and open a handle to it. If the specified name is empty the kernel side object representing the mutex is unnamed and so cannot be opened by name. It can however be passed to another process as a process parameter or via IPC.

By default, any thread in the process can use this instance of RMutex to access the mutex. However, specifying EOwnerThread as the second parameter to this function, means that only the creating thread can use this instance of RMutex to access the mutex; any other thread in this process that wants to access the mutex must either duplicate this handle or use OpenGlobal().

OpenGlobal RHandleBase::Duplicate() TFindMutex

Parameters
aNameThe name to be assigned to this global mutex.
aTypeAn enumeration whose enumerators define the ownership of this mutex handle. If not explicitly specified, EOwnerProcess is taken as default.

(generated from Symbian Developer Library)

◆ CreateLocal()

IMPORT_C TInt RMutex::CreateLocal ( TOwnerType  aType = EOwnerProcess)

Creates a mutex and opens this handle to the mutex.

The kernel side object representing the mutex is unnamed. This means that it is not possible to search for the mutex, which makes it local to the current process.

By default, any thread in the process can use this instance of RMutex to access the mutex. However, specifying EOwnerThread as the parameter to this function, means that only the creating thread can use this instance of RMutex to access the mutex; any other thread in this process that wants to access the mutex must duplicate this handle.

RHandleBase::Duplicate()

Parameters
aTypeAn enumeration whose enumerators define the ownership of this mutex handle. If not explicitly specified, EOwnerProcess is taken as default.

(generated from Symbian Developer Library)

◆ IsHeld()

IMPORT_C TBool RMutex::IsHeld ( )

Test if this mutex is held by the current thread.

(generated from Symbian Developer Library)

◆ Open() [1/3]

TInt RMutex::Open ( const TFindMutex &  aFind,
TOwnerType  aType = EOwnerProcess 
)
inline

Opens a handle to the global mutex found using a TFindMutex object.

A TFindMutex object is used to find all global mutexes whose full names match a specified pattern.

By default, any thread in the process can use this instance of RMutex to access the mutex. However, specifying EOwnerThread as the second parameter to this function, means that only the opening thread can use this instance of RMutex to access the mutex; any other thread in this process that wants to access the mutex must either duplicate the handle or use OpenGlobal() again.

Parameters
aFindA reference to the object which is used to find the mutex.
aTypeAn enumeration whose enumerators define the ownership of this mutex handle. If not explicitly specified, EOwnerProcess is taken as default.

(generated from Symbian Developer Library)

◆ Open() [2/3]

IMPORT_C TInt RMutex::Open ( RMessagePtr2  aMessage,
TInt  aParam,
TOwnerType  aType = EOwnerProcess 
)

Opens a handle to a mutex using a handle number sent by a client to a server.

This function is called by the server.

Parameters
aMessageThe message pointer.
aParamAn index specifying which of the four message arguments contains the handle number.
aTypeAn enumeration whose enumerators define the ownership of this mutex handle. If not explicitly specified, EOwnerProcess is taken as default.

(generated from Symbian Developer Library)

◆ Open() [3/3]

IMPORT_C TInt RMutex::Open ( TInt  aArgumentIndex,
TOwnerType  aType = EOwnerProcess 
)

Opens a handle to a mutex using a handle number passed as an environment data item to the child process during the creation of that child process.

Note that this function can only be called successfully once.

RProcess::SetParameter()

Parameters
aArgumentIndexAn index that identifies the slot in the process environment data that contains the handle number. This is a value relative to zero, i.e. 0 is the first item/slot. This can range from 0 to 15.
aTypeAn enumeration whose enumerators define the ownership of this mutex handle. If not explicitly specified, EOwnerProcess is taken as default.

(generated from Symbian Developer Library)

◆ OpenGlobal()

IMPORT_C TInt RMutex::OpenGlobal ( const TDesC &  aName,
TOwnerType  aType = EOwnerProcess 
)

Opens a handle to a global mutex.

Global mutexes are identified by name.

By default, any thread in the process can use this instance of RMutex to access the mutex. However, specifying EOwnerThread as the second parameter to this function, means that only the opening thread can use this instance of RMutex to access the mutex; any other thread in this process that wants to access the mutex must either duplicate the handle or use OpenGlobal() again.

RHandleBase::Duplicate()

Parameters
aNameThe name of the global mutex which is to be opened.
aTypeAn enumeration whose enumerators define the ownership of this mutex handle. If not explicitly specified, EOwnerProcess is taken as default.

(generated from Symbian Developer Library)

◆ Poll()

IMPORT_C TInt RMutex::Poll ( )

◆ Signal()

IMPORT_C void RMutex::Signal ( )

Release the mutex.

This function decrements the count of how many times the current thread has acquired this mutex. If the count is now zero the mutex is marked as free and, if any other threads are waiting for the mutex to become free, the highest priority among those is made ready to run. However the mutex is not marked as held by any thread - the thread which has just been awakened must actually run in order to acquire the mutex.

Pre-condition
The mutex must previously have been acquired by the current thread calling Wait().

Panic condition: KERN-EXEC 1 If the mutex has not previously been acquired by the current thread calling Wait().

(generated from Symbian Developer Library)

◆ Wait() [1/2]

IMPORT_C void RMutex::Wait ( )

Acquire the mutex, waiting for it to become free if necessary.

This function checks if the mutex is currently held. If not the mutex is marked as held by the current thread and the call returns immediately. If the mutex is held by another thread the current thread will suspend until the mutex becomes free. If the mutex is already held by the current thread a count is maintained of how many times the thread has acquired the mutex.

(generated from Symbian Developer Library)

◆ Wait() [2/2]

IMPORT_C TInt RMutex::Wait ( TInt  aTimeout)

The documentation for this class was generated from the following files: