views:

750

answers:

4

Hi,

in the multi-threaded app I am porting to Symbian using Open C, I have an object that uses an RFile to read/write data to file. This object is supposed to be accessed from different threads (it is threadsafe), however there is the issue that apparently RFile objects can only be accessed within one thread only. As soon as another thread uses the RFile object, I am getting a KERN-EXEC 0.

Is there any way to share the RFile object between different threads? I can't use Active Objects.

+3  A: 

Create a second RFile handle (let's call it secondFile). Don't Open it. Use RFile::Duplicate(secondFile) instead. All the threads in your process should be able to use the secondFile handle after that.

QuickRecipesOnSymbianOS
+1  A: 

Using RFs::ShareAuto() seems to work.

Steven
A: 

You're looking for a combination of:

  1. Transfers an already open file from a server to a client

    RFile::TransferToClient(const RMessage2 &,TInt)const
    
  2. Transfers an already open file to another process

    RFile::TransferToProcess(RProcess &,TInt,TInt)const
    
  3. Transfers an already open file to a server

    RFile::TransferToServer(TIpcArgs &,TInt,TInt)const
    

in the first thread/server/process and

  1. Allows a server to adopt an already open file from a client

    RFile::AdoptFromClient(const RMessage2 &,TInt,TInt)
    
  2. Allows a server to adopt an already open file from a client process

    RFile::AdoptFromCreator(TInt,TInt)
    
  3. Allows a client to adopt an already open file from a server

    RFile::AdoptFromServer(TInt,TInt)
    

.. in the second. This effectively duplicates the file handle allowing both to use it.

If transferring between threads in the same process then you can more simply use

RFile::Duplicate(const RFile &,TOwnerType)
Dynite
A: 

useful information.

http://zipclue.com

faris