Location:
e32cmn.h
Link against: euser.lib
class RSemaphore : public RHandleBase;
A handle to a semaphore.
The semaphore itself is a Kernel side object.
As with all handles, they should be closed after use. RHandleBase
provides the necessary Close()
function, which should be called when the handle is no longer required.
RHandleBase
- A handle to an object
RSemaphore
- A handle to a semaphore
Defined in RSemaphore
:
CreateGlobal()
, CreateLocal()
, Open()
, Open()
, Open()
, OpenGlobal()
, Signal()
, Signal()
, Wait()
, Wait()
Inherited from RHandleBase
:
Attributes()
,
Close()
,
Duplicate()
,
FullName()
,
Handle()
,
HandleInfo()
,
Name()
,
SetHandle()
,
SetHandleNC()
,
SetReturnedHandle()
,
iHandle
inline TInt Open(const TFindSemaphore &aFind, TOwnerType aType=EOwnerProcess);
Opens a handle to the global semaphore found using a TFindSemaphore
object.
ATFindSemaphore
object is used to find all global semaphores whose full names match a specified pattern.
By default, any thread in the process can use this instance of RSemaphore to access the semaphore. However, specifying EOwnerThread
as the second parameter to this function, means that only the opening thread can use this instance of RSemaphore to access
the semaphore; any other thread in this process that wants to access the semaphore must either duplicate the handle or use
OpenGlobal()
again.
|
|
IMPORT_C TInt CreateLocal(TInt aCount, TOwnerType aType=EOwnerProcess);
Creates a semaphore, setting its initial count, and opens this handle to the semaphore.
The kernel side object representing the semaphore is unnamed. This means that it is not possible to search for the semaphore, which makes it local to the current process.
By default, any thread in the process can use this instance of RSemaphore to access the semaphore. However, specifying EOwnerThread as the second parameter to this function, means that only the creating thread can use this instance of RSemaphore to access the semaphore; any other thread in this process that wants to access the semaphore must duplicate this handle.
|
|
|
IMPORT_C TInt CreateGlobal(const TDesC &aName, TInt aCount, TOwnerType aType=EOwnerProcess);
Creates a global semaphore, setting its initial count, and opens this handle to the semaphore.
The kernel side object representing the semaphore 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 semaphore, using TFindSemaphore
, and open a handle to it. If the specified name is empty the kernel side object representing the semaphore 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 RSemaphore to access the semaphore. However, specifying EOwnerThread
as the third parameter to this function, means that only the creating thread can use this instance of RSemaphore to access
the semaphore; any other thread in this process that wants to access the semaphore must either duplicate this handle or use
OpenGlobal()
.
|
|
|
IMPORT_C TInt OpenGlobal(const TDesC &aName, TOwnerType aType=EOwnerProcess);
Opens a handle to a global semaphore.
Global semaphores are identified by name.
By default, any thread in the process can use this instance of RSemaphore to access the semaphore. However, specifying EOwnerThread
as the second parameter to this function, means that only the opening thread can use this instance of RSemaphore to access
the semaphore; any other thread in this process that wants to access the semaphore must either duplicate the handle or use
OpenGlobal()
again.
|
|
IMPORT_C TInt Open(RMessagePtr2 aMessage, TInt aParam, TOwnerType aType=EOwnerProcess);
Opens a handle to a semaphore using a handle number sent by a client to a server.
This function is called by the server.
|
|
IMPORT_C TInt Open(TInt aArgumentIndex, TOwnerType aType=EOwnerProcess);
Opens a handle to a semaphore 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.
|
|
IMPORT_C void Wait();
Waits for a signal on the semaphore.
The function decrements the semaphore count by one and returns immediately if it is zero or positive.
If the semaphore count is negative after being decremented, the calling thread is added to a queue of threads maintained by this semaphore.
The thread waits until the semaphore is signalled. More than one thread can be waiting on a particular semaphore at a time. When there are multiple threads waiting on a semaphore, they are released in priority order.
If the semaphore is deleted, all threads waiting on that semaphore are released.
IMPORT_C TInt Wait(TInt aTimeout);
Waits for a signal on the semaphore, or a timeout.
|
|
IMPORT_C void Signal();
Signals the semaphore once.
The function increments the semaphore count by one. If the count was negative before being incremented, the highest priority thread waiting on the semaphore's queue of threads is removed from that queue and, provided that it is not suspended for any other reason, is marked as ready to run.
IMPORT_C void Signal(TInt aCount);
Signals the semaphore one or more times.
The function increments the semaphore count. If the count was negative before being incremented, the highest priority thread waiting on the semaphore's queue of threads is removed from that queue and, provided that it is not suspended for any other reason, is marked as ready to run.
|