This page was last modified 13:07, 24 June 2008.
Inter-Process Data Transfer
From Forum Nokia Wiki
Contents |
Introduction
If two threads belong to different processes, they cannot manipulate each other’s data directly because they don’t share the same address space. Two methods of RThread, ReadL() and WriteL(), can be used to copy 8- or 16-bit data between the address spaces of the current thread and a thread represented by the RThread handle. The current thread and the other thread can belong to the same or to different processes.
Data transfer is implemented by copying descriptors or part of them. RThread provides functions to return the length and maximum length of a descriptor located in its address space.
Reading from the descriptor of another thread
void ReadL(const TAny* aPtr,TDes8& aDes,TInt anOffset) const; void ReadL(const TAny* aPtr,TDes16 &aDes,TInt anOffset) const;
The ReadL() method copies a block of data from the descriptor (pointed to by aPtr) of the other thread to the descriptor aDes of the current thread. The aPtr pointer must point to a valid descriptor within the address space of the thread represented by the RThread handle. The contents of the source descriptor starting from the anOffset position are copied into the target descriptor aDes. The copied data will be truncated if its length exceeds the maximum length of aDes.
Writing to the descriptor of another thread
void WriteL(const TAny* aPtr,const TDesC8& aDes,TInt anOffset) const; void WriteL(const TAny* aPtr,const TDesC16& aDes,TInt anOffset) const;
The WriteL() method copies all data from descriptor aDes of the current thread to the descriptor of the other thread (pointed to by aPtr). The anOffset parameter sets the initial copy position of a target descriptor. The aPtr pointer must point to a valid modifiable descriptor within the current thread’s address space. If the length of data to be copied plus anOffset exceeds the maximum length of the target descriptor, the function leaves.
Descriptor helper functions
TInt GetDesLength(const TAny* aPtr) const; TInt GetDesMaxLength(const TAny* aPtr) const;
The RThread method GetDesLength() returns the length of a descriptor pointed to by aPtr. The descriptor must be located within the address space of the thread represented by this RThread handle. The RThread method GetMaxDesLength() returns the maximum length of a descriptor pointed to by aPtr. The descriptor must be located within the address space of the thread represented by this RThread handle. The use of these functions before calling ReadL() and WriteL() is recommended.
--
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| RChunk::CreateLocal returns KErrOverflow | lenclud | General Symbian C++ | 7 | 2007-10-02 10:22 |
| bluetooth plug and play | guillaume17 | Bluetooth Technology | 6 | 2005-01-18 09:41 |
| Image Processing | pankajmahto | General Symbian C++ | 0 | 2004-01-20 14:20 |
| DRM for bluetooth transfer | paperclip | Digital Rights Management & Content Downloading | 11 | 2008-03-13 12:39 |
| Nokia 6060 - unable to sync data | GunDamZero13 | General Discussion | 8 | 2006-07-22 09:58 |
