|
||
class RThread : public RHandleBase;
A handle to a thread.
The thread itself is a kernel object.
RHandleBase
- A handle to an object.
RThread
- A handle to a thread.
Defined in RThread
:
Context(TDes8 &)const
Gets the register contents of this thread.Create(const TDesC &,TThreadFunction,TInt,RAllocator *,TAny *,TOwnerType)
Creates a thread belonging to the current process, and opens this handle to that...Create(const TDesC &,TThreadFunction,TInt,TAny *,RLibrary *,RHeap *,TInt,TInt,TOwnerType)
Function only temporarily supported to aid migration to process emulation...Create(const TDesC &,TThreadFunction,TInt,TInt,TInt,TAny *,TOwnerType)
Creates a thread belonging to the current process, and opens this handle to that...ExitCategory()const
Gets the name of the category associated with the end of the thread.ExitReason()const
Gets the specific reason associated with the end of this thread.ExitType()const
Tests whether the thread has ended and, if it has ended, return how it ended.GetCpuTime(TTimeIntervalMicroSeconds &)const
Gets the CPU usage for this thread.HandleCount(TInt &,TInt &)const
Gets the number of handles open in this thread, and the number of handles open i...HasCapability(TCapability,TCapability,const char *)const
Check if the process to which the thread belongs has both of the given capabilit...HasCapability(TCapability,const char *)const
Check if the process to which the thread belongs has a given capabilityId()const
Gets the Id of this thread.Kill(TInt)
Ends the thread, specifying a reason code.Logon(TRequestStatus &)const
Requests notification when this thread dies, normally or otherwise.LogonCancel(TRequestStatus &)const
Cancels an outstanding request for notification of the death of this thread.Open(TThreadId,TOwnerType)
Opens a handle to the thread with a specific thread Id.Open(const TDesC &,TOwnerType)
Opens a handle to specifically named thread.Open(const TFindThread &,TOwnerType)
Opens a handle to the thread found by pattern matching a name.Panic(const TDesC &,TInt)
Panics this thread, specifying the panic category name and reason.Priority()const
Gets the priority of this thread.Process(RProcess &)const
Opens a process-relative handle to the process which owns this thread.ProcessPriority()const
Gets the priority of the process which owns this thread.RThread()
Default constructor.RenameMe(const TDesC &)
Rendezvous(TInt)
Completes all Rendezvous' with the current thread.Rendezvous(TRequestStatus &)const
Creates a Rendezvous request with the thread.RendezvousCancel(TRequestStatus &)const
Cancels a previously requested Rendezvous with the threadRequestComplete(TRequestStatus *&,TInt)const
Signals this thread that an asynchronous request originating from this thread, i...RequestCount()const
Gets this thread's request semaphore count.RequestSignal()const
Signal this threads request semaphore.Resume()const
Makes the thread eligible for execution.SecureId()const
Return the Secure ID of the process to which the thread belongs.SetPriority(TThreadPriority)const
Sets the priority of the thread to one of the values defined by the TThreadPrior...SetProcessPriority(TProcessPriority)const
Sets the priority of the process which owns this thread to one of the values def...StackInfo(TThreadStackInfo &)const
Gets information about a thread's user mode stack.Suspend()const
Suspends execution of this thread.Terminate(TInt)
Ends the thread, specifying a reason code.VendorId()const
Return the Vendor ID of the process to which the thread belongs.Inherited from RHandleBase
:
Attributes()const
BTraceId()const
Returns a unique object identifier for use with BTrace
Close()
Closes the handle.Duplicate(const RThread &,TOwnerType)
Creates a valid handle to the kernel object for which the specified thread alrea...FullName()const
Gets the full name of the handle.FullName(TDes &)const
Gets the full name of the handle.Handle()const
Retrieves the handle-number of the object associated with this handle.HandleInfo(THandleInfo *)
Gets information about the handle.Name()const
Gets the name of the handle.Open(const TFindHandleBase &,TOwnerType)
Opens a handle to a kernel side object found using a find-handle object.RHandleBase(TInt)
Copy constructor.SetHandle(TInt)
Sets the handle-number of this handle to the specified value.SetHandleNC(TInt)
Sets the handle-number of this handle to the specified value, and marks it as no...SetReturnedHandle(TInt)
Sets the handle-number of this handle to the specified value.iHandle
inline RThread();
Default constructor.
The constructor exists to initialise private data within this handle; it does not create the thread object.
Specifically, it sets the handle-number to the value KCurrentThreadHandle. In effect, the constructor creates a default thread handle.
IMPORT_C TInt Create(const TDesC &aName, TThreadFunction aFunction, TInt aStackSize, TInt aHeapMinSize, TInt aHeapMaxSize,
TAny *aPtr, TOwnerType aType=EOwnerProcess);
Creates a thread belonging to the current process, and opens this handle to that thread.
A new heap is created for this thread.
By default, ownership of this thread handle is vested in the current process, but can be vested in the current thread by passing EOwnerThread as the second parameter to this function.
If KNullDesC is specified for the name, then an anonymous thread will be created. Anonymous threads are not global, and cannot be opened by other processes.
|
|
|
IMPORT_C TInt Create(const TDesC &aName, TThreadFunction aFunction, TInt aStackSize, RAllocator *aHeap, TAny *aPtr, TOwnerType
aType=EOwnerProcess);
Creates a thread belonging to the current process, and opens this handle to that thread.
This thread uses the heap whose handle is pointed to by aAllocator. If this is NULL, then the thread uses the heap of the creating thread.
By default, ownership of this thread handle is vested in the current process, but can be vested in the current thread by passing EOwnerThread as the second parameter to this function.
If KNullDesC is specified for the name, then an anonymous thread will be created. Anonymous threads are not global, and cannot be opened by other processes.
|
|
|
IMPORT_C TInt Open(const TDesC &aFullName, TOwnerType aType=EOwnerProcess);
Opens a handle to specifically named thread.
By default, ownership of this thread handle is vested in the current process, but can be vested in the current thread by passing EOwnerThread as the second parameter to this function.
|
|
IMPORT_C TInt Open(TThreadId aID, TOwnerType aType=EOwnerProcess);
Opens a handle to the thread with a specific thread Id.
By default, ownership of this thread handle is vested in the current process, but can be vested in the current thread by passing EOwnerThread as the second parameter to this function.
|
|
IMPORT_C TThreadId Id() const;
Gets the Id of this thread.
|
IMPORT_C void Resume() const;
Makes the thread eligible for execution.
After a thread is created, it is put into a suspended state; the thread is not eligible to run until RThread::Resume()const
is called.
This function must also be called to resume execution of this thread after it has been explicitly suspended by a call to RThread::Suspend()const
.
Note that when a thread is created, it is given the priority EPriorityNormal by default. The fact that a thread is initially
put into a suspended state means that the thread priority can be changed by calling the thread's RThread::SetPriority(TThreadPriority)const
member function before the thread is started by a call to RThread::Resume()const
.
IMPORT_C void Suspend() const;
Suspends execution of this thread.
The thread is not scheduled to run until a subsequent call to RThread::Resume()const
is made.
Interface status: | deprecated | Use User::RenameThread() instead |
static inline TInt RenameMe(const TDesC &aName);
|
|
IMPORT_C void Kill(TInt aReason);
Ends the thread, specifying a reason code.
This function is dangerous and should be used only in cases where the target thread cannot end itself via the normal methods
of calling User::Exit(TInt)
or completing its thread function. A hypothetical example might be where a thread gets 'stuck' in a third-party DLL.
The target thread gets no opportunity to execute any clean-up code, therefore incautious use of this function may lead to memory leaks.
It is functionally identical to RThread::Terminate(TInt)
, the only difference between the two is a legacy distinction between a 'normal' reason for exiting (use Kill) and an 'abnormal'
reason (use Terminate). The choice of function is reflected in the return value of RThread::ExitType()const
.
The thread must be in the current process otherwise a panic is raised.
If the thread is process permanent, or the thread is the last thread in the process, then the process is also killed. If the thread is system permanent, the entire system is rebooted.
WARNING: If the target thread uses a shared heap then use of this function will cause an internal array used for thread-local storage (TLS) to be leaked. This leak is specific to ARM platforms which implement the CP15 feature and will not occur on other platforms.
|
User::Exit(TInt)
Terminates the current thread, specifying a reason. All child threads are termin...User::SetCritical(TCritical)
Sets up or changes the effect that termination of the current thread has, either...User::Critical()
Gets the critical state associated with the current thread.RThread::Terminate(TInt)
Ends the thread, specifying a reason code.RThread::ExitType()const
Tests whether the thread has ended and, if it has ended, return how it ended.IMPORT_C void Terminate(TInt aReason);
Ends the thread, specifying a reason code.
This function is dangerous and should be used only in cases where the target thread cannot end itself via the normal methods
of calling User::Exit(TInt)
or completing its thread function. A hypothetical example might be where a thread gets 'stuck' in a third-party DLL.
The target thread gets no opportunity to execute any clean-up code, therefore incautious use of this function may lead to memory leaks.
It is functionally identical to RThread::Kill(TInt)
, the only difference between the two is a legacy distinction between a 'normal' reason for exiting (use Kill) and an 'abnormal'
reason (use Terminate). The choice of function is reflected in the return value of RThread::ExitType()const
.
The thread must be in the current process otherwise a panic is raised.
If the thread is process critical or process permanent, or the thread is the last thread in the process, then the process is also terminated. If the thread is system critical or system permanent, the entire system is rebooted.
WARNING: If the target thread uses a shared heap then use of this function will cause an internal array used for thread-local storage (TLS) to be leaked. This leak is specific to ARM platforms which implement the CP15 feature and will not occur on other platforms.
|
User::Exit(TInt)
Terminates the current thread, specifying a reason. All child threads are termin...User::SetCritical(TCritical)
Sets up or changes the effect that termination of the current thread has, either...User::Critical()
Gets the critical state associated with the current thread.RThread::Kill(TInt)
Ends the thread, specifying a reason code.RThread::ExitType()const
Tests whether the thread has ended and, if it has ended, return how it ended.IMPORT_C void Panic(const TDesC &aCategory, TInt aReason);
Panics this thread, specifying the panic category name and reason.
The length of the category name should be no greater than 16; any name with a length greater than 16 is truncated to 16.
The calling thread, i.e. the thread in which this function is called, must be in the same process as this target thread, otherwise the calling thread is itself panicked.
If the thread is process critical or process permanent, the process also panics. If the thread is system critical or system permanent, the entire system is rebooted.
|
|
User::SetCritical(TCritical)
Sets up or changes the effect that termination of the current thread has, either...User::Critical()
Gets the critical state associated with the current thread.IMPORT_C TInt Process(RProcess &aProcess) const;
Opens a process-relative handle to the process which owns this thread.
The caller must construct a default RProcess
object and pass this to the function. On return, aProcess is the open process-relative handle to the process owning this
thread.
The return value indicates the success or failure of this function.
|
|
IMPORT_C TThreadPriority Priority() const;
Gets the priority of this thread.
|
Capability: | ProtServ | if aPriority is EPriorityAbsoluteRealTime1 or higher |
IMPORT_C void SetPriority(TThreadPriority aPriority) const;
Sets the priority of the thread to one of the values defined by the TThreadPriority enumeration.
The resulting absolute priority of the thread depends on the value of aPriority and the priority of the owning process.
Use of the priority value EPriorityNull is restricted to Symbian OS, and any attempt to explicitly set this value causes a KERN-EXEC 14 panic to be raised.
|
|
IMPORT_C TProcessPriority ProcessPriority() const;
Gets the priority of the process which owns this thread.
|
Interface status: | deprecated | Not allowed on threads in a different process. Replace with RProcess::SetPriority or RMessagePtr2::SetProcessPriority |
IMPORT_C void SetProcessPriority(TProcessPriority aPriority) const;
Sets the priority of the process which owns this thread to one of the values defined by the TProcessPriority enumeration.
The priority can be set to one of the four values:
EPriorityLow
EPriorityBackground
EPriorityForeground
EPriorityHigh
The absolute priority of all threads owned by the process (and all threads owned by those threads etc.) are re-calculated.
Note:
The use of the priority values EPriorityWindowServer, EPriorityFileServer, EPriorityRealTimeServer and EPrioritySupervisor is restricted to Symbian OS, and any attempt to explicitly set any of these priority values raises a KERN-EXEC 14 panic.
|
IMPORT_C TInt RequestCount() const;
Gets this thread's request semaphore count.
The request semaphore is created when a thread is created, and is used to support asynchronous requests.
A negative value implies that this thread is waiting for at least one asynchronous request to complete.
|
IMPORT_C TExitType ExitType() const;
Tests whether the thread has ended and, if it has ended, return how it ended.
This information allows the caller to distinguish between normal termination and a panic.
|
IMPORT_C TInt ExitReason() const;
Gets the specific reason associated with the end of this thread.
The reason number together with the category name is a way of distinguishing between different causes of thread termination.
If the thread has panicked, this value is the panic number. If the thread has ended as a result of a call to RThread::Kill(TInt)
, then the value is the one supplied by RThread::Kill(TInt)
.
If the thread is still alive, then the returned value is zero.
|
IMPORT_C TExitCategoryName ExitCategory() const;
Gets the name of the category associated with the end of the thread.
The category name together with the reason number is a way of distinguishing between different causes of thread termination.
If the thread has panicked, the category name is the panic category name; for example, E32USER-CBase or KERN-EXEC. If the
thread has ended as a result of call to RThread::Kill(TInt)
, then the category name is Kill.
If the thread has not ended, then the category name is empty, i.e. the length of the category name is zero.
|
TBuf
A build-independent modifiable buffer descriptor.IMPORT_C void RequestComplete(TRequestStatus *&aStatus, TInt aReason) const;
Signals this thread that an asynchronous request originating from this thread, is complete.
The request is associated with the specified request status object supplied by this thread.
Typically, the caller of this function is the service provider responsible for satisfying the request made by this thread.
The request is completed with the completion code passed in aReason. This value is copied into this thread's request status, *aStatus, before signalling this thread's request semaphore.
The meaning of the completion code is a matter of convention to be decided between the service provider and this thread.
In a client-server situation, completion of a request takes place in the context of the server thread, but the pointer is interpreted in the address space of the client.
It is often the case in client-server situations that the client and the server are in the same address space (i.e. the same process).
Setting the pointer to the request status to NULL is a convenience, not all servers need it.
|
IMPORT_C void RequestSignal() const;
Signal this threads request semaphore.
This is similar to RThread::RequestComplete(TRequestStatus *&,TInt)const
except that no TRequestStatus
object is modified.
May only be used to signal a thread in the same process as the callers.
|
IMPORT_C void Logon(TRequestStatus &aStatus) const;
Requests notification when this thread dies, normally or otherwise.
A request for notification is an asynchronous request, and completes:
when the thread terminates
if the outstanding request is cancelled by a call to RThread::LogonCancel(TRequestStatus &)const
.
A request for notification requires memory to be allocated; if this is unavailable, then the call to RThread::Logon(TRequestStatus &)const
returns, and the asynchronous request completes immediately.
Note that even when a thread has died, it is not possible to create a new thread with the same name until all handles on the
dead thread have been closed. If this is attempted, the call to RThread::Create(const TDesC &,TThreadFunction,TInt,TInt,TInt,TAny *,TOwnerType)
will fail with KErrAlreadyExists.
|
RThread::LogonCancel(TRequestStatus &)const
Cancels an outstanding request for notification of the death of this thread.RThread::ExitReason()const
Gets the specific reason associated with the end of this thread.RThread::Create(const TDesC &,TThreadFunction,TInt,TInt,TInt,TAny *,TOwnerType)
Creates a thread belonging to the current process, and opens this handle to that...IMPORT_C TInt LogonCancel(TRequestStatus &aStatus) const;
Cancels an outstanding request for notification of the death of this thread.
A request for notification must previously have been made, otherwise the function returns KErrGeneral.
The caller passes a reference to the same request status object as was passed in the original call to RThread::Logon(TRequestStatus &)const
.
|
|
IMPORT_C void HandleCount(TInt &aProcessHandleCount, TInt &aThreadHandleCount) const;
Gets the number of handles open in this thread, and the number of handles open in the process which owns this thread.
|
IMPORT_C void Context(TDes8 &aDes) const;
Gets the register contents of this thread.
|
IMPORT_C TInt StackInfo(TThreadStackInfo &aInfo) const;
Gets information about a thread's user mode stack.
|
|
IMPORT_C TInt GetCpuTime(TTimeIntervalMicroSeconds &aCpuTime) const;
Gets the CPU usage for this thread.
This function is not supported on version 8.0b or 8.1b, and returns KErrNotSupported. From 9.1 onwards it may be supported if the kernel has been compiled with the MONITOR_THREAD_CPU_TIME macro defined.
KErrNotSupported - if this feature is not supported on this version or build of the OS.
|
|
inline TInt Open(const TFindThread &aFind, TOwnerType aType=EOwnerProcess);
Opens a handle to the thread found by pattern matching a name.
ATFindThread
object is used to find all threads whose full names match a specified pattern.
By default, ownership of this thread handle is vested in the current process, but can be vested in the current thread by passing EOwnerThread as the second parameter to this function.
|
|
IMPORT_C void Rendezvous(TRequestStatus &aStatus) const;
Creates a Rendezvous request with the thread.
The request is an asynchronous request, and completes:
when the thread next calls RThread::Rendezvous(TInt)
if the outstanding request is cancelled by a call to RThread::RendezvousCancel(TRequestStatus &)const
if the thread exits
if the thread panics.
Note that a request requires memory to be allocated; if this is unavailable, then this call to RThread::Rendezvous(TRequestStatus &)const
returns, and the asynchronous request completes immediately.
|
RThread::Rendezvous(TInt)
Completes all Rendezvous' with the current thread.IMPORT_C TInt RendezvousCancel(TRequestStatus &aStatus) const;
Cancels a previously requested Rendezvous with the thread
The request completes with the value KErrCancel (if it was still outstanding).
|
|
IMPORT_C static void Rendezvous(TInt aReason);
Completes all Rendezvous' with the current thread.
|
IMPORT_C TSecureId SecureId() const;
Return the Secure ID of the process to which the thread belongs.
If an intended use of this method is to check that the Secure ID is a given value, then the use of a TSecurityPolicy
object should be considered. E.g. Instead of something like:
RThread& thread;
TInt error = thread.SecureId()==KRequiredSecureId ? KErrNone : KErrPermissionDenied;
this could be used;
RThread& thread;
static _LIT_SECURITY_POLICY_S0(mySidPolicy, KRequiredSecureId);
TInt error = mySidPolicy().CheckPolicy(thread);
This has the benefit that the TSecurityPolicy::CheckPolicy(RProcess,const char *)const
methods are configured by the system wide Platform Security configuration. I.e. are capable of emitting diagnostic messages
when a check fails and/or the check can be forced to always pass.
|
TSecurityPolicy::CheckPolicy(RThread,const char *)const
Checks this policy against the platform security attributes of the process ownin...IMPORT_C TVendorId VendorId() const;
Return the Vendor ID of the process to which the thread belongs.
If an intended use of this method is to check that the Vendor ID is a given value, then the use of a TSecurityPolicy
object should be considered. E.g. Instead of something like:
RThread& thread;
TInt error = thread.VendorId()==KRequiredVendorId ? KErrNone : KErrPermissionDenied;
this could be used;
RThread& thread;
static _LIT_SECURITY_POLICY_V0(myVidPolicy, KRequiredVendorId);
TInt error = myVidPolicy().CheckPolicy(thread);
This has the benefit that the TSecurityPolicy::CheckPolicy(RProcess,const char *)const
methods are configured by the system wide Platform Security configuration. I.e. are capable of emitting diagnostic messages
when a check fails and/or the check can be forced to always pass.
|
TSecurityPolicy::CheckPolicy(RThread,const char *)const
Checks this policy against the platform security attributes of the process ownin...inline TBool HasCapability(TCapability aCapability, const char *aDiagnostic=0) const;
Check if the process to which the thread belongs has a given capability
When a check fails the action taken is determined by the system wide Platform Security configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. If PlatSecEnforcement is OFF, then this function will return ETrue even though the check failed.
|
|
inline TBool HasCapability(TCapability aCapability1, TCapability aCapability2, const char *aDiagnostic=0) const;
Check if the process to which the thread belongs has both of the given capabilities
When a check fails the action taken is determined by the system wide Platform Security configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. If PlatSecEnforcement is OFF, then this function will return ETrue even though the check failed.
|
|
Interface status: | deprecated | Use process emulation instead |
inline TInt Create(const TDesC &aName, TThreadFunction aFunction, TInt aStackSize, TAny *aPtr, RLibrary *aLibrary, RHeap *aHeap,
TInt aHeapMinSize, TInt aHeapMaxSize, TOwnerType aType);
Function only temporarily supported to aid migration to process emulation...
|
|