regarding active objects..........
| Sat, 2007-11-24 21:19 | |
|
HI, I have an active object class. A() B() There are 2 other functions C() and D() I need that after asynchronous completion of A(), C() is executed in RunL() Can it be done under a single Active object class I feel that there is some way of doing this in a single class but not so sure Can any one tell how? Regards! |
|






Forum posts: 159
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.
Forum posts: 137
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
Forum posts: 137
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
Forum posts: 159
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
Forum posts: 137
other codes inside A() and B() are different......
Forum posts: 116
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....
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