×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    21

    not able to acesss data through rchunk

    hi all,

    i created a class and stores the pointer in global rchunk,

    process 1
    class CMyClassublic CBase
    {
    public
    cMyClass2* C;
    }
    CMyClass* iPtr;
    class CMyClass2ublic CBase
    {
    TInt iRef;
    }


    m storing iPtr in rchunk
    now i want to access the data of the class in some other process
    now when i try to acess in
    process 2
    TInt ref = iPtr->iPtr->iRef
    ref am getting "0" alwaz ,whatever be the value i stores in process 1


    please give some coomment

  2. #2
    Registered User
    Join Date
    Sep 2007
    Posts
    21

    Re: not able to acesss data through rchunk

    i just want to add,this is working fine on emulator,but not on device

  3. #3
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: not able to acesss data through rchunk

    There are three problems with this:

    a) You need to store the contents of the pointer in the chunk as well. The pointer references a block of memory owned by another process and so process isolation will prevent access to the contents of the other pointer. Basic if (p != NULL) DoSomething(); is ok, but if (p != NULL) p->DoSomething is not ok
    b) You need to prevent concurrent access so the two threads/processes do not overlap reading and writing of the data
    c) When you call RChunk::Base you get different values in different processes.

    See the url below for more info
    http://library.forum.nokia.com/index...nks.guide.html
    Download Symbian OS now! [url]http://developer.symbian.org[/url]

  4. #4
    Registered User
    Join Date
    Sep 2007
    Posts
    21

    Re: not able to acesss data through rchunk

    thanks todd,i think this is the problem,mean i need to copy the second class pointer also on the chunk

  5. #5
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: not able to acesss data through rchunk

    As I said in the other link, what you have to do is:
    Lock the chunk so only you have access to it (using a semaphore)
    Copy the data into the chunk as the data (normally via ExternalizeL)- NO POINTERS OR HANDLES ALLOWED!!!!
    Unlock the chunk
    Tell the other process to recreate the object, normally this is via InternalizeL

    Remember the RChunk::Base remaps the pointers to the process so any internal pointers in one address will not neccessarily correspond to pointers in another process space.

    Chunks are designed to pass memory block blocks around, not raw structures or pointers and especially not virtual method tables. Good uses for chunks include pictures and files. Bad examples include C++ objects, linked lists, pointer arrays.

    Use client/server, thats what it is there for
    Download Symbian OS now! [url]http://developer.symbian.org[/url]

  6. #6
    Registered User
    Join Date
    Dec 2004
    Posts
    110

    Re: not able to acesss data through rchunk

    Hi all,

    i have a large structured file which is about 4.5 MB and i want to load it once and share it between different processe that using my dll, so i'm trying to use global heap chunk through the User method but i couldn't acheive it and what i understood is that i have to create a global chunck and write to or read from but i didn't find any example indicates how could i write and read from the chunk also i don't need to copy the data from the chunk to other process can i switch to it directly

    Thanks in advance

Similar Threads

  1. Replies: 2
    Last Post: 2008-07-03, 15:29
  2. Replies: 4
    Last Post: 2006-08-30, 10:15
  3. Replies: 2
    Last Post: 2006-08-11, 20:51
  4. Accessing data in RChunk objects...
    By profoundwhispers in forum Symbian C++
    Replies: 1
    Last Post: 2006-06-13, 15:56
  5. Unicode Song Title In NSM Ringtone
    By mcai7db3 in forum Smart Messaging
    Replies: 3
    Last Post: 2002-08-28, 06:58

Posting Permissions

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