regarding active objects..........

Login to reply to this topic.
Sat, 2007-11-24 21:19
Joined: 2007-05-15
Forum posts: 137

HI,
I am somewhat confused at a point.

I have an active object class.
There are 2 asynchronous methods in it A() and B(),i.e., they submit request by calling setactive().

A()
{
-----------
-----------
iImage->Convert(&iStatus,aBitmap,iFrameData);
setactive();
}

B()
{
-----------
-----------
iImage->Convert(&iStatus,aBitmap,iFrameData);
setactive();
}

There are 2 other functions C() and D()

I need that after asynchronous completion of A(), C() is executed in RunL()
and after asynchronous completion of B(),D() is executed in RunL()

Can it be done under a single Active object class
or do i require to use 2 separate Active Object classes

I feel that there is some way of doing this in a single class but not so sure

Can any one tell how?

Regards!
Sandeep Mohapatra!


Sat, 2007-11-24 23:51
Joined: 2007-09-23
Forum posts: 159
Re: regarding active objects..........

You can only do it if A and B are called mutually exclusively from each other, i.e you call a and then get runl or you call b and then get runl, you can't call a and b and then get runl, for that you need two active objects.

Sun, 2007-11-25 06:32
Joined: 2007-05-15
Forum posts: 137
Re: regarding active objects..........

Sorry could nt get you.
I have the following scenario:-

activeobj.cpp
------------------
A()
{
-----------
-----------
iImage->Convert(&iStatus,aBitmap,iFrameData);
setactive();
}

B()
{
-----------
-----------
iImage->Convert(&iStatus,aBitmap,iFrameData);
setactive();
}
RunL()
{
}

FROM AN OUTSIDE Class
--------------------------------------
X()
{
--------------
A();
-------------
------------
B();
---------------
}

So, in effect I need to find out if the request completed for A() or B(). Is this possible

can it be done in a single active obj class

Sun, 2007-11-25 11:04
Joined: 2007-05-15
Forum posts: 137
Re: regarding active objects..........

Hi,
I am thinking of something.But am not sure if it is technically correct.

in activeobj.h
--------------------
TBool iFlag;

in activeobj.cpp
---------------------
constructor of activeobj()
{
---------------------
---------------------
iFlag=ETrue;
}

------------------
A()
{
-----------
-----------
iImage->Convert(&iStatus,aBitmap,iFrameData);
iFlag=ETrue;
setactive();
}

B()
{
-----------
-----------
iImage->Convert(&iStatus,aBitmap,iFrameData);
iFlag=EFalse;
setactive();
}
RunL()
{
if(iFlag) {iFlag=!iFlag;C();}
else {iFlag=!iFlag;D();}

}

FROM AN OUTSIDE Class
--------------------------------------
X()
{
--------------
A();
-------------
------------
B();
---------------
}

Wish someone comment on this....

Regards!
Sandeep Mohapatra

Mon, 2007-11-26 01:48
Joined: 2007-09-23
Forum posts: 159
Re: regarding active objects..........

No you can't do this, you need two active objects because you have the same TRequestStatus being passed to two asynchronous functions at the same time in your code.

But I don't understand why you want this anyway as you're calling exactly the same things with the same parameters in A and B

Mon, 2007-11-26 02:09
Joined: 2007-05-15
Forum posts: 137
Re: regarding active objects..........

other codes inside A() and B() are different......

Mon, 2007-11-26 10:05
Joined: 2007-09-20
Forum posts: 116
Re: regarding active objects..........

Hi,

Using a single active object for 2 different asynch request is not advisable.
Think of a scenario where AO::A() is called and before the completion of this requeset AO::B() is called.... Puzzled

If the method AO::B() is called only after the completion of AO::A() this is OK.
i.e;

X()
{
--------------
A();
-------------
WaitForCompletionOfA();
B();
---------------
}

In this case you can use a TBool variable as you have mentioned earlier, but this is not a very good solution. Using two AO to handle the two different tasks would be a better solution.


Chao,
Raghav

  • Login to reply to this topic.