×

Discussion Board

Results 1 to 5 of 5

Thread: RThread

  1. #1
    Regular Contributor
    Join Date
    Dec 2003
    Posts
    470

    RThread

    Hello friends,

    I have a problem with symbian threads. I'am using the RThread class and as said in the documentation, I'am using a Thread function to execute the code I want to run in the thread. But I see that all the objects (The object pointers are not local) I created in the Thread function are destroyed after the thread function is completed. Since the object pointers are not local, the objects should be accessible even after the thread function is complete. This is happening in the series 60 emulator. Have any idea. Are there any spacial things to take care of when using RThread.

    Best regards
    Jaak

  2. #2
    Registered User
    Join Date
    Oct 2005
    Posts
    6

    Re: RThread

    Jaak,

    To a thread is associated a heap. When you create objects using the 'new' operator, they are created on the heap. When your thread function terminates, the thread terminates and therefoer its heap is not available anymore. Also you shouldn't try to access memory allocated in one thread from another thread, this will not work with recent version of SymbianOS. Use the client/server API for inter-thread communication.

    Olivier.

  3. #3
    Regular Contributor
    Join Date
    Dec 2003
    Posts
    470

    Re: RThread

    Thanks for the reply.

    I suppose, the interprocess communication is done using the Read and Write
    functions. The first parameter of both functions is a TAny*. But a descriptor is expected here. But I want to pass the pointer of an application specific object here. Is this possible.

    For example User is a class in my application. In my thread I will create a user object and I want to pass it to the main thread. Is this possible.

    Best Regards,
    Jaak

  4. #4
    Registered User
    Join Date
    Oct 2005
    Posts
    6

    Re: RThread

    Jaak,

    Yes you can pass objects from one thread to another using the client/server API. This is a bit long to explain in a forum so I suggest you read about the client/server API in the SymbianOS SDK docs and look at the sample code in the /examples/base/ipc/clientserver/simple directory.

    Olivier.

  5. #5
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    393

    Re: RThread

    Hi,

    There is also a Threads example on this site under the Symbian Examples section. It demonstrates thread synchronisation over a shared counter, which uses Thread Local Storage to share data between threads.

    I think you need this approach rather than a client server approach. You could store the pointer to the object in TLS.

    Regards,
    Nitin

Similar Threads

  1. Rthread Problem..
    By sym_coder in forum Symbian
    Replies: 0
    Last Post: 2005-10-19, 05:21
  2. Rthread samples or multithreading samples?
    By mayur_24 in forum Symbian
    Replies: 0
    Last Post: 2004-07-16, 14:23
  3. Process name from RThread
    By cirbre in forum Symbian
    Replies: 5
    Last Post: 2003-11-13, 10:08
  4. RThread - parameter to the thread function
    By EduardFrank in forum Symbian
    Replies: 2
    Last Post: 2002-10-24, 06:11
  5. Problem with CMdaAudioPlayerUtility and RThread
    By EduardFrank in forum Symbian
    Replies: 1
    Last Post: 2002-10-14, 18:26

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×