×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Regular Contributor
    Join Date
    May 2009
    Posts
    51

    Question Is it possible for a class to handle multiple active objects?

    Hi,

    I have a class that currently intercepts mailbox events vis MMsvSessionObserver. I would also like to implement an RTimer event so I can delay another part of my processing (basically I have a synchronous function that checks GPS coords periodically - I want to wait until coords of sufficient "quality" have been obtained).

    Can I in the same class as the one that implements MMsvSessionObserver also handle the active object RTimer?

    My SMS handler RunL function is:
    Code:
    void CSmsHandler::RunL()
    {
        User::LeaveIfError( iStatus != KErrNone );
    
        // Determine the current operations progress.
        // ProgressL returns an 8 bit descriptor.
        if (iOperation)
        {
    		TBufC8<KMsvProgressBufferLength> progress( iOperation->ProgressL() );
    		_LIT8( KCompare, "KErrNone" );
    		User::LeaveIfError( !progress.Compare( KCompare ) );
        }
    
        // The pointer to the current CMsvOperation object is no longer needed.
        delete iOperation;
        iOperation = NULL;
    
        // Determine which request has finished.
        switch ( iState )
    	{
    		case EWaitingForMoving:
    		{
    			// Once a message is moved to Outbox it is scheduled for sending.
    			ScheduleL();
    			break;
    		}
    
    		case EWaitingForScheduling:
    		{
    			TMsvEntry entry( iSmsMtm->Entry().Entry() );
    			TInt state( entry.SendingState() );
    
    			if ( state == KMsvSendStateWaiting || state == KMsvSendStateScheduled)
    			{
    
    			}
    
    			break;
    		}
    
    		default:
    			break;
    	}
    }
    Thanks for any assistance,
    MR

  2. #2
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    125

    Re: Is it possible for a class to handle multiple active objects?

    ya ... you can use RTimer... and use that in a seperate function and invoke SetActive() from it.... and switch to appropriate in RUNL... only thing you should do is to make sure that there are no outstanding requests of any Active objects before calling RTimer... So you should issue cancel() for all the active objects......

  3. #3
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    125

    Re: Is it possible for a class to handle multiple active objects?

    if you forgot to cancel requests you will get CBase 42 panic......

  4. #4
    Regular Contributor
    Join Date
    May 2009
    Posts
    51

    Re: Is it possible for a class to handle multiple active objects?

    Quote Originally Posted by manjusg View Post
    ya ... you can use RTimer... and use that in a seperate function and invoke SetActive() from it.... and switch to appropriate in RUNL... only thing you should do is to make sure that there are no outstanding requests of any Active objects before calling RTimer... So you should issue cancel() for all the active objects......
    How do I tell whether the RTimer expired or a message server event occurred in RunL? I can't see a way to differentiate.

    What I have done is create a class that handles RTimer's events and triggers a function in the parent class when the timer expires. I guess this is the preferred way anyway.

  5. #5
    Registered User
    Join Date
    Jan 2007
    Posts
    282

    Re: Is it possible for a class to handle multiple active objects?

    A much better way would be to use single tick CPeriodic object. It only needs a callback function and doesn't require an active object. So using CPeriodic would make it possible to have all your code inside a single Active class rather then spanning multiple classes as in case of RTimer.

    There`s an wiki example to use CPeriodic http://wiki.forum.nokia.com/index.ph...tream_of_ticks.

    Hope that helps,
    VJ

  6. #6
    Regular Contributor
    Join Date
    May 2009
    Posts
    51

    Re: Is it possible for a class to handle multiple active objects?

    Quote Originally Posted by vaibhavjain View Post
    There`s an wiki example to use CPeriodic http://wiki.forum.nokia.com/index.ph...tream_of_ticks.
    So I set the initial triggered time to say 1s and the interval time to something arbitrarily large and "cancel" the CPeriodic timer in the callback?

    From what I understand of the CPeriodic, it uses RTimer internally anyway?

  7. #7
    Registered User
    Join Date
    Jan 2007
    Posts
    282

    Re: Is it possible for a class to handle multiple active objects?

    Quote Originally Posted by mratnam View Post
    So I set the initial triggered time to say 1s and the interval time to something arbitrarily large and "cancel" the CPeriodic timer in the callback?
    Yes , however you will be canceling the timer on first callback hence value of interval time will be irrelevant.

    Quote Originally Posted by mratnam View Post
    From what I understand of the CPeriodic, it uses RTimer internally anyway?
    True all classes deriving from CTimer (including CPeriodic) use RTimer internally.

  8. #8
    Regular Contributor
    Join Date
    May 2009
    Posts
    51

    Post Re: Is it possible for a class to handle multiple active objects?

    Quote Originally Posted by vaibhavjain View Post
    Yes , however you will be canceling the timer on first callback hence value of interval time will be irrelevant.

    True all classes deriving from CTimer (including CPeriodic) use RTimer internally.
    Great. Thanks for the responses.

Similar Threads

  1. External Linking Error (Undefined Symbol)
    By nile_mail in forum Symbian
    Replies: 2
    Last Post: 2008-08-05, 13:10
  2. need information about j2me polish
    By rathikathangaraj in forum Mobile Java General
    Replies: 4
    Last Post: 2007-12-19, 09:01
  3. Replies: 2
    Last Post: 2007-10-05, 20:40
  4. Client/server arch to make active objects communicate
    By micmail in forum Bluetooth Technology
    Replies: 0
    Last Post: 2006-08-17, 14:07
  5. panicking active objects
    By kratom in forum Symbian
    Replies: 0
    Last Post: 2003-04-18, 07:20

Posting Permissions

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