Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: e32std.h
Link against: euser.lib

Class RThread

RThread

Support

Supported from 5.0

Description

A handle to a thread.

The thread itself is a Kernel object.

Derivation

RHandleBaseHandle to an object
RThreadA handle to a thread

Defined in RThread:
Context(), Create(), ExceptionHandler(), ExitCategory(), ExitReason(), ExitType(), GetCpuTime(), GetDesLength(), GetDesMaxLength(), GetRamSizes(), HandleCount(), Heap(), Id(), IsExceptionHandled(), Kill(), Logon(), LogonCancel(), ModifyExceptionMask(), Open(), Panic(), Priority(), Process(), ProcessPriority(), Protected(), RThread(), RaiseException(), ReadL(), Rename(), RequestComplete(), RequestCount(), Resume(), SetExceptionHandler(), SetInitialParameter(), SetPriority(), SetProcessPriority(), SetProtected(), Suspend(), WriteL()

Inherited from RHandleBase:
Close(), Duplicate(), Handle(), SetHandle()


Construction and destruction


RThread()

RThread();

Description

Constructs this object.

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, defined in e32std.h. In effect, construction of RThread creates a default thread handle.

[Top]


Create a new thread


Create()

TInt Create(const TDesC& aName,TThreadFunction aFunction,TInt aStackSize,TInt aHeapMinSize,TInt aHeapMaxSize,TAny *aPtr,TOwnerType aType=EOwnerProcess);

Description

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.

Note:

A pointer to data can be passed to the thread function after the thread has been created by calling the RThread::SetInitialParameter() function.

The heap for this new thread shares the chunk with the program stack and has type EChunkStack.

Parameters

const TDesC& aName

The name to be assigned to this thread

TThreadFunction aFunction

A pointer to a function.. Control passes to this function when the thread is first resumed, i.e. when the thread is initially scheduled to run.

TInt aStackSize

The size of the new thread's stack; this must not be negative, otherwise the function raises a USER 109 panic.

TAny* aPtr

A pointer to data to be passed as a parameter to the thread function when the thread is initially scheduled to run. If the thread function does not need any data then this pointer can be NULL.

TInt aHeapMinSize

The minimum size for the new thread's heap; this value must be greater than or equal to KMinHeapSize, defined in e32std.h, otherwise the function raises a USER 110 panic.

TInt aHeapMaxSize

The maximum size for the new thread's heap; this value must be greater than or equal to aHeapMinSize, otherwise the function raises a USER 111 panic.

TOwnerType aType

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

Return value

TInt

KErrNone if successful otherwise another of the system-wide error codes.

See also:


Create()

TInt Create(const TDesC& aName,TThreadFunction aFunction,TInt aStackSize,RHeap* aHeap,TAny* aPtr,TOwnerType aType=EOwnerProcess);

Description

Creates a thread belonging to the current process and to open this handle to that thread.

This thread uses the heap whose handle, an RHeap object, is pointed to by aHeap. 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.

Note that a pointer to data can be passed to the thread function after the thread has been created by calling the RThread::SetInitialParameter() function.

Parameters

const TDesC& aName

The name to be assigned to this thread

TThreadFunction aFunction

A pointer to a function. Control passes to this function when the thread is first resumed, i.e. when the thread is initially scheduled to run

TInt aStackSize

The size of the new thread's stack; this must not be negative, otherwise the function raises a USER 109 panic

RHeap* aHeap

A pointer to the handle of the heap belonging to another thread which this thread is to use.

TAny* aPtr

A pointer to data to be passed as a parameter to the thread function when the thread is initially scheduled to run. If the thread function does not need any data then this pointer can be NULL.

TOwnerType aType

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

Return value

TInt

KErrNone if successful otherwise another of the system-wide error codes.

See also:


Create()

TInt Create(const RProcess& aProcess,const TDesC& aName,TThreadFunction aFunction,TInt aStackSize,TInt aHeapMinSize,TInt aHeapMaxSize,TAny* aPtr,TOwnerType aType=EOwnerProcess);

Support

Withdrawn in 6.0

Description

Creates a thread belonging to the process identified by a process handle, 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.

Note that a pointer to data can be passed to the thread function after the thread has been created by calling the RThread::SetInitialParameter() function.

Parameters

RProcess* aProcess

A reference to the handle of the process in which the new thread belongs.

const TDesC& aName

The name to be assigned to this thread.

TThreadFunction aFunction

A pointer to a function. Control passes to this function when the thread is first resumed, i.e. when the thread is initially scheduled to run.

TInt aStackSize

The size of the new thread's stack; this must not be negative, otherwise the function raises a USER 109 panic.

TInt aHeapMinSize

The minimum size for the new thread's heap; this value must be greater than or equal to KMinHeapSize, defined in e32std.h, otherwise the function raises a USER 110 panic.

TInt aHeapMaxSize

The maximum size for the new thread's heap; this value must be greater than or equal to aHeapMinSize, otherwise the function raises a USER 111 panic.

TAny* aPtr

A pointer to data to be passed as a parameter to the thread function when the thread is initially scheduled to run. If the thread function does not need any data then this pointer can be NULL.

TOwnerType aType

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

Return value

TInt

KErrNone if successful otherwise another of the system-wide error codes.

See also:


Create()

TInt Create(const TDesC& aName,TThreadFunction aFunction,TInt aStackSize,TAny* aPtr,RLibrary* aLibrary,RProcess* aProcess,RHeap* aHeap, TInt aHeapMinSize,TInt aHeapMaxSize,TOwnerType aType);

Support

Withdrawn in 6.0

Description

Creates a thread where the thread function belongs to a DLL, and opens this handle to that thread.

This thread belongs to the process identified by the handle aProcess, if aProcess is not NULL, otherwise the thread belongs to the current process.

If the handle aHeap is NULL, a new heap is created for this thread, otherwise this thread uses the heap associated with that handle.

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.

Note that a pointer to data can be passed to the thread function after the thread has been created by calling the RThread::SetInitialParameter() function.

Parameters

const TDesC& aName

The name to be assigned to this thread.

TThreadFunction aFunction

A pointer to a function. Control passes to this function when the thread is first resumed, i.e. when the thread is initially scheduled to run

TInt aStackSize

The size of the new thread's stack; this must not be negative, otherwise the function raises a USER 109 panic.

TAny* aPtr

A pointer to data to be passed as a parameter to the thread function when the thread is initially scheduled to run. If the thread function does not need any data then this pointer can be NULL.

RLibrary* aLibrary

A pointer to a handle to a library (DLL) in which the thread function, aFunction, resides. The function accepts a NULL pointer.

RProcess* aProcess

A reference to the handle of the process in which the new thread belongs. If NULL, the new thread belongs to the current process.

RHeap* aHeap

A pointer to the handle of an existing heap which the new thread is to use. The heap must also be of type RHeap::EChunkNormal or RHeap::EChunkStack, otherwise the function raises a USER 108 panic. If NULL, a new heap is created.

TInt aHeapMinSize

The minimum size for the new thread's heap; this value must be greater than or equal to KMinHeapSize, defined in e32std.h, otherwise the function raises a USER 110 panic. This value is only used if aHeap is NULL.

TInt aHeapMaxSize

The maximum size for the new thread's heap; this value must be greater than or equal to aHeapMinSize, otherwise the function raises a USER 111 panic. This value is only used if aHeap is NULL.

TOwnerType aType

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

Return value

TInt

KErrNone if successful otherwise another of the system-wide error codes.

See also:


Create()

TInt Create(const TDesC& aName,TThreadFunction aFunction,TInt aStackSize,TAny* aPtr,RLibrary* aLibrary,RHeap* aHeap, TInt aHeapMinSize,TInt aHeapMaxSize,TOwnerType aType);

Support

Supported from 6.0

Description

Creates a thread where the thread function belongs to a DLL, and opens this handle to that thread.

This thread belongs to the current process.

If the handle aHeap is NULL, a new heap is created for this thread, otherwise this thread uses the heap associated with that handle.

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.

Note that a pointer to data can be passed to the thread function after the thread has been created by calling the RThread::SetInitialParameter() function.

Parameters

const TDesC& aName

The name to be assigned to this thread.

TThreadFunction aFunction

A pointer to a function. Control passes to this function when the thread is first resumed, i.e. when the thread is initially scheduled to run

TInt aStackSize

The size of the new thread's stack; this must not be negative, otherwise the function raises a USER 109 panic.

TAny* aPtr

A pointer to data to be passed as a parameter to the thread function when the thread is initially scheduled to run. If the thread function does not need any data then this pointer can be NULL.

RLibrary* aLibrary

A pointer to a handle to a library (DLL) in which the thread function, aFunction, resides. The function accepts a NULL pointer.

RHeap* aHeap

A pointer to the handle of an existing heap which the new thread is to use. The heap must also be of type RHeap::EChunkNormal or RHeap::EChunkStack, otherwise the function raises a USER 108 panic. If NULL, a new heap is created.

TInt aHeapMinSize

The minimum size for the new thread's heap; this value must be greater than or equal to KMinHeapSize, defined in e32std.h, otherwise the function raises a USER 110 panic. This value is only used if aHeap is NULL.

TInt aHeapMaxSize

The maximum size for the new thread's heap; this value must be greater than or equal to aHeapMinSize, otherwise the function raises a USER 111 panic. This value is only used if aHeap is NULL.

TOwnerType aType

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

Return value

TInt

KErrNone if successful otherwise another of the system-wide error codes.

See also:


SetInitialParameter()

TInt SetInitialParameter(TAny* aPtr);

Description

Sets the initial parameter for this thread's thread-function.

The thread must currently be in a suspended state, otherwise SetInitialParameter() returns KErrGeneral.

The pointer to the data to be passed to the thread-function is normally passed on creation of this thread handle (i.e. the RThread) using one of the Create() member functions of RThread.

The SetInitialParameter() function allows the initial parameter to point to a cell within this thread's own heap. The thread-function can then call User::Free() on that cell.

Parameters

TAny* aPtr

A pointer to data; this pointer is passed as the argument to the thread-function. The meaning of the data depends on the thread function.

Return value

TInt

KErrNone if successful or KErrGeneral if function is called when the thread is not suspended.

[Top]


Open a handle to an existing thread


Open()

TInt Open(const TDesC& aFullName,TOwnerType aType=EOwnerProcess);

Description

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.

Parameters

const TDesC& aFullName

A reference to the descriptor containing the full name of the thread to be opened.

TOwnerType aType

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

Return value

TInt

KErrNone if successful otherwise another of the system-wide error codes.


Open()

TInt Open(const TFindThread& aFind,TOwnerType aType=EOwnerProcess);

Description

Opens a handle to the thread found by pattern matching a name.

A TFindThread 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.

Parameters

const TFindThread& aFind

A reference to the TFindThread object used to find the thread.

TOwnerType aType

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

Return value

TInt

KErrNone if successful otherwise another of the system-wide error codes.


Open()

TInt Open(TThreadId aID,TOwnerType aType=EOwnerProcess);

Description

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.

Parameters

TThreadId aId

The thread Id used to find the thread.

TOwnerType aType

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

Return value

TInt

KErrNone if successful otherwise another of the system-wide error codes.

[Top]


Open a handle to the owning process


Process()

TInt Process(RProcess& aProcess) const;

Description

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.

Parameters

RProcess& aProcess

A reference to a default RProcess handle; on successful return from this function, this is the process-relative handle to the process which owns this thread.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.

[Top]


Renaming a thread


Rename()

TInt Rename(const TDesC& aName) const;

Description

Assigns a new name to this thread, replacing any existing name which may have been set by Create() or by an earlier call to Rename().

Any attempt to rename a thread which is protected and is different from the thread invoking this function, causes the rename operation to fail. A thread can call Rename() on itself whether it is protected or not.

The new name must be a valid name and it must also be such that the thread's new fullname remains unique amongst threads.

Parameters

const TDesC& aName

A reference to the descriptor containing the new name of the thread.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes. Specifically:KErrBadName, if aName is an invalidKErrAlreadyExists, if a thread with the same fullname as that generated from aName already exists.

[Top]


Get or set the thread priority


Priority()

TThreadPriority Priority() const;

Description

Gets the priority of this thread.

Return value

TThreadPriority

The priority. Note that this is not necessarily the absolute priority of the thread.


SetPriority()

void SetPriority(TThreadPriority aPriority) const;

Description

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.

Parameters

TThreadPriority aPriority

The priority value. The enumeration is defined in e32std.h.

Notes:

[Top]


Retrieving and setting the priority of the owning process


ProcessPriority()

TProcessPriority ProcessPriority() const;

Description

Gets the priority of the process which owns this thread.

Return value

TProcessPriority

The process priority.


SetProcessPriority()

void SetProcessPriority(TProcessPriority aPriority) const;

Description

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:

The absolute priority of all threads owned by the process (and all threads owned by those threads etc.) are re-calculated.

Note:

Parameters

TProcessPriority aPriority

The priority value; the enumeration is defined in e32std.h.

[Top]


Controlling execution of the thread


Resume()

void Resume() const;

Description

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 Resume() is called.

This function must also be called to resume execution of this thread after it has been explicitly suspended by a call to Suspend().

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 SetPriority() member function before the thread is started by a call to Resume().


Suspend()

void Suspend() const;

Description

Suspends execution of this thread. The thread is not scheduled to run until a subsequent call to Resume() is made.

Notes:


Kill()

void Kill(TInt aReason);

Description

Ends this thread specifying a reason code.

If the thread is waiting on a semaphore or mutex, the wait is cancelled. If the thread is ready to run, it is removed from the list of threads eligible to run. Any mutexes owned by the thread are freed and any remaining resources are freed or cleaned up.

If this is the main thread of a process, then the process is ended.

Parameters

TInt aReason

The reason to be associated with the ending of this thread.

Notes:

See also:


Panic()

void Panic(const TDesC& aCategory,TInt aReason);

Description

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.

Parameters

const TDesC& aCategory

A reference to the descriptor containing the text which defines the category name for this panic.

TInt aReason

The panic number.

Notes:

[Top]


Information about thread termination


ExitType()

TExitType ExitType() const;

Description

Has the thread ended and, if it has ended, return how it ended.

This information allows the caller to distinguish between normal termination and a panic.

Return value

TExitType

An enumeration whose enumerators describe how the thread has ended.


ExitReason()

TInt ExitReason() const;

Description

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 Kill(), then the value is the one supplied by Kill().

If the thread is still alive, then the returned value is zero.

Return value

TInt

The reason associated with the end of the thread.


ExitCategory()

TExitCategoryName ExitCategory() const;

Description

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 Kill(), 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.

Return value

TExitCategoryName

A TBuf descriptor with a defined maximum length containing the name of the category associated with the end of the thread.

See also:

[Top]


Notification of death of this thread


Logon()

void Logon(TRequestStatus& aStatus) const;

Description

Requests notification when this thread dies, normally or otherwise.

A request for notification is an asynchronous request.

The request completes when the thread terminates or, if an outstanding notification request is cancelled by a call to this thread's LogonCancel() member function.

A request for notification requires memory to be allocated; if this is unavailable, the call to Logon() returns but the asynchronous request completes immediately with the value KErrNoMemory.

Call RThread::ExitType() to find out how the thread died.

Parameters

TRequestStatus& aStatus

A reference to the request status object. This contains the return value from the function passed into the thread. Alternatively, this is set to:KErrCancel, if an outstanding request is cancelled.KErrNoMemory, if there is insufficient memory.


LogonCancel()

TInt LogonCancel(TRequestStatus& aStatus) const;

Description

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 Logon().

Parameters

TRequestStatus& aStatus

A reference to the same request status object used in the original call to Logon().

Return value

TInt

KErrGeneral if there is no outstanding request, KErrNone otherwise.

[Top]


Information about this thread


RequestCount()

TInt RequestCount() const;

Description

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.

Return value

TInt

This thread's request semaphore count.

See also:


HandleCount()

void HandleCount(TInt& aProcessHandleCount, TInt& aThreadHandleCount) const;

Description

Gets the number of handles open in this thread and the number of handles open in the process which owns this thread.

Parameters

TInt& aProcessHandleCount

On return from this function, contains the number of handles open in the process which owns this thread on return from this function.

TInt& aThreadHandleCount

On return from this function, contains the number of handles open in this thread.


Id()

TThreadId Id() const;

Description

Gets the Id of this thread.

Return value

TThreadId

The Id of this thread


GetRamSizes()

TInt GetRamSizes(TInt& aHeapSize,TInt& aStackSize);

Description

Gets the size of the heap and the stack for this thread.

Parameters

TInt& aHeapSize

A reference to a signed integer supplied by the caller. On return from this function, contains the size of this thread's heap.

TInt& aStackSize

A reference to a signed integer supplied by the caller. On return from this function, contains the size of this thread's stack.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


GetCpuTime()

TInt GetCpuTime(TTimeIntervalMicroSeconds& aCpuTime) const;

Support

Supported from 6.1

Description

Gets the CPU usage for this thread.

Parameters

TTimeIntervalMicroSeconds& aCpuTime

A reference to a time interval object supplied by the caller. On return from this function, contains the CPU usage for this thread.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


Protected()

TBool Protected() const;

Description

Tests whether this thread is protected.

The protected state prevents any other thread from setting the priority, suspending, ending or panicking this thread.

Return value

TBool

True, if the thread is protected; false, otherwise.

[Top]


Setting thread attributes


SetProtected()

void SetProtected(TBool aState) const;

Description

Sets the thread into a protected state.

The protected state prevents any other thread from setting the priority, suspending, ending or panicking this thread.

Parameters

TBool aState

True, if the thread is to be protected; false, otherwise.

[Top]


Signal request completion


RequestComplete()

void RequestComplete(TRequestStatus*& aStatus,TInt aReason) const;

Description

Signals to 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.

Parameters

TRequestStatus*& aStatus

A reference to a pointer to the request status originally supplied by this thread. This is a pointer into this thread's address space, which may be different to the thread currently executing (this code). On return, the pointer to the request status is set to NULL.

TInt aReason

The completion code of this request.

Notes:

[Top]


Inter-thread communication functions


GetDesLength()

TInt GetDesLength(const TAny* aPtr) const;

Description

Gets the length of a specified descriptor within the address space in which the thread represented by this handle runs.

Although aPtr is of type TAny*, it is assumed to point to a valid descriptor, i.e. a TDesC derived object. If the object at aPtr is not recognised as a valid descriptor, then the function returns with KErrBadDescriptor.

Parameters

const TAny* aPtr

A pointer to a location within this thread's address space. The location is expected to contain a TDesC derived object.

Return value

TInt

If non-negative, the length of the descriptor at location aPtr within this thread's address space. If negative, one of the system-wide error codes.Specifically:KErrArgument, if aPtr does not point to a valid location within this thread's address space.KErrBadDescriptor if aPtr does not point to a valid descriptor.


GetDesMaxLength()

TInt GetDesMaxLength(const TAny* aPtr) const;

Description

Gets the maximum length of a specified modifiable descriptor within the address space in which the thread represented by this thread handle runs.

Although aPtr is of type TAny*, it is assumed to point to be a modifiable descriptor, i.e. a TDes derived object (for example a TPtr or a TBuf<TInt>). If the object at aPtr is not recognized as a valid descriptor, then the function returns with KErrBadDescriptor.

Parameters

const TAny* aPtr

A pointer to a location within this thread's address space. The location is expected to contain a TDes derived object.

Return value

TInt

If non-negative, the maximum length of the descriptor at location aPtr within this thread's address space. If negative, one of the system-wide error codes. Specifically:KErrArgument, if aPtr does not point to a valid location within this thread's address space.KErrBadDescriptor if aPtr does not point to a valid descriptor.


ReadL()

void ReadL(const TAny* aPtr,TDes8& aDes,TInt anOffset) const;
void ReadL(const TAny* aPtr,TDes16 &aDes,TInt anOffset) const;

Description

Copies data from a specified descriptor — within the address space in which the thread represented by this RThread handle runs — to a specified descriptor in the current thread.

Although the source of this copy operation, aPtr, is of type TAny*, it is assumed to point to a valid descriptor, i.e. a TDesC8 or TDesC16 derived object. If the object at aPtr is not recognised as a valid descriptor, then the function leaves.

Data is copied from position anOffset within the source descriptor data area. The length of data copied is the length of the source descriptor minus the value of anOffset.

If the value of anOffset is greater than the length of the source descriptor, then no data is copied and the length of aDes, the target descriptor, is set to zero.

The length of data to be copied cannot be greater than the maximum length of aDes, the target descriptor. If this is the case, then the length of data copied is limited to the maximum length of aDes.

Parameters

const TAny* aPtr

A pointer to the source for this copy operation. It is assumed to point to a valid descriptor within this thread's address space.

TDes8& aDes

A reference to the target descriptor (8 bit) for this copy operation belonging to the caller's address space.

TDes16& aDes

A reference to the target descriptor (16 bit) for this copy operation belonging to the caller's address space.

TInt anOffset

The offset from the start of the source descriptor data area from where copying is to begin. This value must be greater than or equal to zero.

Leave codes

 

The function leaves for a number of reasons which are summarised here. This RThread handle must be a valid handle, otherwise the function leaves with KErrBadHandle . anOffset must be greater than or equal to zero, otherwise the function leaves with KErrArgument . aPtr must point to a valid location within this thread's address space, otherwise the function leaves with KErrArgument . aPtr must also point to a valid descriptor, otherwise the function leaves with KErrBadDescriptor .

Notes:


WriteL()

void WriteL(const TAny* aPtr,const TDesC8& aDes,TInt anOffset) const;
void WriteL(const TAny* aPtr,const TDesC16& aDes,TInt anOffset) const;

Description

Copies data to a specified modifiable descriptor — within the address space in which the thread represented by this RThread handle runs — from a specified descriptor in the current thread.

Although the target of this copy operation, aPtr, is of type TAny*, it is assumed to point to a valid modifiable type descriptor, i.e. a TDes type. If the object at aPtr is not recognised as a valid descriptor, then the function leaves.

Data is copied from the source descriptor, aDes, to position anOffset within the target descriptor data area. The length of data copied is the length of the source descriptor, aDes. The length of the target descriptor is set to the length of the source descriptor plus the value of anOffset (i.e. aDes.Length() + anOffset).

The target descriptor data area must be big enough to contain the data; specifically, the maximum length of the target descriptor must be sufficient to contain data of length (aDes.Length() plus anOffset), otherwise the function leaves.

Parameters

const TAny* aPtr

A pointer to the target for this copy operation. It is assumed to point to a valid modifiable descriptor within this thread's address space.

const TDesC8& aDes

A reference to the source descriptor (8 bit) for this copy operation belonging to the caller's address space.

const TDesC16& aDes

A reference to the source descriptor (16 bit) for this copy operation belonging to the caller's address space.

TInt anOffset

The offset from the start of the target descriptor data where copying is to begin. This value must be greater than or equal to zero.

Leave codes

 

The function leaves for a number of reasons which are summarised here. This RThread handle must be a valid handle, otherwise the function leaves with KErrBadHandle . anOffset must be greater than or equal to zero, otherwise the function leaves with KErrArgument . aPtr must point to a valid location within this thread's address space, otherwise the function leaves with KErrArgument . aPtr must also point to a valid descriptor, otherwise the function leaves with KErrBadDescriptor . There must be sufficient space available within the target chunk for the copy operation to complete; specifically, if there is insufficient space for a target descriptor object or the target descriptor's length is less than the space really available in the chunk, then the function leaves with either KErrArgument or KErrBadDescriptor . The length of the target descriptor must be sufficient to contain the newly copied data, otherwise the function leaves with KErrOverflow .

Notes:

[Top]


Accessing the thread’s heap


Heap()

RHeap* Heap();

Description

Gets a pointer to the handle to this thread's heap.

Return value

RHeap*

A pointer to the handle to this thread's heap.

[Top]


Exception handling


ExceptionHandler()

TExceptionHandler* ExceptionHandler() const;

Description

Gets a pointer to this thread's exception handler.

Return value

TExceptionHandler*

A pointer to the exception handler.


SetExceptionHandler()

TInt SetExceptionHandler(TExceptionHandler* aHandler,TUint32 aMask);

Description

Sets the thread's current exception handler.

Parameters

TExceptionHandler* aHandler

A pointer to the new exception handler.

TUint32 aMask

One or more flags defining the exception categories which the handler aHandler can handle.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.

See also:


ModifyExceptionMask()

void ModifyExceptionMask(TUint32 aClearMask, TUint32 aSetMask);

Description

Changes the set of exceptions which this thread's exception handler can deal with.

aClearMask is the set of flags defining the set of exceptions which the exception handler no longer deals with while aSetMask is the set of flags defining the new set of exceptions to be set.

Flag clearing is done before flag setting.

Parameters

TUint32 aClearMask

One or more flags defining the exceptions which the current exception handler no longer deals with.

TUint32 aSetMask

One or more flags defining the new set of exceptions which the current exception handler is to deal with.

See also:


RaiseException()

TInt RaiseException(TExcType aType);

Description

Raises an exception of a specified type on this thread.

If this thread has an exception handler to handle this type of exception, then it is called.

If this thread has no exception handler to handle this type of exception, then the result depends on whether this thread is the same as the current thread or not:

Parameters

TExcType aType

The type of exception.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.

Notes:


IsExceptionHandled()

TBool IsExceptionHandled(TExcType aType);

Description

Tests whether a specified exception type can be handled by this thread.

If the thread has no exception handler, then this function returns false.

If the thread has an exception handler which cannot handle the type of exception defined by aType, then the function returns false.

Parameters

TExcType aType

The type of exception.

Return value

TBool

True, if the thread has an exception handler which can handle an exception of type aType; false, otherwise.

[Top]


Register contents of sleeping thread


Context()

void Context(TDes8& aDes) const;

Description

Gets the register contents of this (sleeping) thread.

Parameters

TDes8& aDes

On return, contains the register contents, starting with R0.