×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    60

    Start 2 functions, but dont wait till the first is finished - Active Object?

    hi,

    id like to start a function e.g. calculate() and right after that the copydir(); function.
    copydir() should not wait till calculate() is finished, because it takes some time.
    I need no info when calculate() is finished.

    Is there an easy way to achief this? or do i need to create an active object or similar?




    calculate();
    copydir();
    ...

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,567

    Re: Start 2 functions, but dont wait till the first is finished - Active Object?

    Active objects are callbacks executed in a serialized manner. http://www.developer.nokia.com/Commu...tive_Scheduler contains a more-or-less correct code about how the scheduler works. As you can see it has a loop, and invokes RunL-s depending on their iStatus. But only one RunL is running at a time.
    In special cases, preferably with loops inside, it is possible to decompose a long running task into several steps, and create a self completing active object for running it "parallel". In case of a "for" loop, the loop variable can be made a member variable, and RunL takes one step of processing, then increments the loop variable, and re-schedules itself if necessary. Your long running calculation could probably do that.
    However in a Symbian C++ application everything is running in a single Active Scheduler, so your other tasks should be de-composed too, like the copydir stuff.
    On the other hand you can use threads (RThread), which are really running in parallel to your main code. The downside is that threads can not call into GUI code (Symbian GUI resources are accessible from the primary thread only), so tracking the happenings with your thread still requires some active object wrapper.
    Note that the SDK contains some really simple examples, look for Fibonacci1-2-3 somewhere in Examples\Base\IPC\Async, or similar (I have no SDK here, so can not check). Fibonacci1 shows calculating Fibonacci numbers synchronously. Fibonacci2 puts the calculation in a separate thread, and shows the usage of RThread::Logon. Fibonacci3 decomposes the same task with a self-triggering active object.

  3. #3
    Registered User
    Join Date
    Mar 2012
    Posts
    60

    Re: Start 2 functions, but dont wait till the first is finished - Active Object?

    ok, thanks for the detailed explanation. i will have a look at the Fibonacci examples.

Similar Threads

  1. On Application Start Launch a active object
    By Sohil in forum Symbian C++
    Replies: 3
    Last Post: 2007-06-29, 11:56
  2. stop and start active object
    By ceehira in forum Symbian C++
    Replies: 3
    Last Post: 2006-07-10, 13:58
  3. Start a thread inside Active object?
    By tanechka_a in forum Symbian C++
    Replies: 0
    Last Post: 2005-12-13, 17:01
  4. Wait Note and Active Object
    By windalfred0 in forum Symbian C++
    Replies: 6
    Last Post: 2004-11-16, 04:13
  5. Wait Note and Active Object
    By windalfred0 in forum Symbian User Interface
    Replies: 8
    Last Post: 2004-09-09, 10:23

Posting Permissions

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