Why my Active Object is Working?

Login to reply to this topic.
Fri, 2008-07-11 09:23
Joined: 2007-11-07
Forum posts: 15

According to AO pattern:
1. We have to check for existing request if its not.
2. Do request
3. Signal Active Scheduler.

I Changed my order like 1->3->2 and found that its working fine in below scenarios:

My Active Object Class:

CMyHandlerAO * CMyHandlerAO::NewL()
   {
   CMyHandlerAO * self = NewLC();
   CleanupStack::Pop(self);
   return (self );
   }

CMyHandlerAO * CMyHandlerAO::NewLC()
   {
   CMyHandlerAO * self = new ( ELeave ) CMyHandlerAO ();
   CleanupStack::PushL(self);
   self->ConstructL();
   return self;
   }

void CMyHandlerAO::ConstructL()
  {
  //Without any request
  SetActive();
  }

void CMyHandlerAO::RunL()
   {       
   switch (iStatus.Int() )
       {
       ………………………
       ………………………
       }
    }
TRequestStatus& CMyHandlerAO::Status()
   {
   return iStatus;
   }

Senario 1:

TInt RMySrv::Connect()
   {
    …………………………
    …………………………
   iCMyHandlerAO = CMyHandlerAO::NewL();
   RTimer timer;                    
   timer.CreateLocal();
   timer.At(i CMyHandlerAO -> Status(),time);
   return CreateSession(KMyServerName,CMyServer::Version(),
                        KDefaultMessageSlots);
    }

Its working fine.

Scenario 2::

void RMySrv::SetData()
  {
  ...............................
  iCMyHandlerAO2 = CMyHandlerAO::NewL();
   ……………………….
   ……………………….
   sendrecieve(iCMyHandlerAO2-> Status(),payloadData);
   ...............................
  }

Its working fine.

Scenario 3:

TInt RMySrv::Connect()
   {
    …………………………
    …………………………
   iCMyHandlerAO1 = CMyHandlerAO::NewL();
   return CreateSession(KMyServerName,CMyServer::Version(),
                        KDefaultMessageSlots);
    }
void RMySrv::SetData()
  {
   ……………………….
   ……………………….
   sendrecieve(iCMyHandlerAO1-> Status(),payloadData);
   ...............................
  }

Its not working i am getting stray signal in connect() (as expected).

Can anyone tell me why its working fine in scenario 1 and 2 but not in scenario 3.


Wed, 2008-07-23 21:43
Joined: 2005-07-28
Forum posts: 121
Re: Why my Active Object is Working?

Try ensuring that SetActive is called after you've invoked your async call.

When SetActive() is set to true, and iStatus does not equal KRequestPending, then the active scheduler will invoke the RunL() since the Active Scheduler will think your active object has had it's request serviced.

After:

TInt RMySrv::Connect()
   {
    …………………………
    …………………………
   iCMyHandlerAO1 = CMyHandlerAO::NewL();
   return CreateSession(KMyServerName,CMyServer::Version(),
                        KDefaultMessageSlots);
    }

iStatus = 0 (zero into of CBase class)
iActive = True

If createSession causes the active scheduler to run through it's loop, then the CMyHandlerAO::RunL() will be called and the iActive set to False.

iStatus = 0
iActive = False

void RMySrv::SetData()
  {
   ……………………….
   ……………………….
   sendrecieve(iCMyHandlerAO1-> Status(),payloadData);
   ...............................
  }

Result : Stray signal.

  • Login to reply to this topic.