[Ace-users] Re: ACE_Task and ACE_Event_Handler

ak akaraban at gmail.com
Wed Aug 29 09:56:14 CDT 2007


Thank you for helping Dr :)

> BTW, *always* make sure to check the return values of any methods you
> call to make sure things are working properly.
activate() returns 0.

>>loop
> >{
> > ThreadPool.putq(MessageBlock);
> Aha, so is this blocking the handle_timeout() call?  If so, that's why
> you're not getting any other timers dispatched..
No. After each iteration I put loop to sleep by ACE_OS::sleep(500 ms).
I have 5 working threads and every thread takes about 2-3 minutes to
process received message.

> Right, but you need to make sure that you have a separate thread
> running to handle timers.
Probably I should have named topic like
ACE_Thread_Timer_Queue_Adapter<ACE_Timer_Heap> and ACE_Task.
because I'm using ACE_Thread_Timer_Queue_Adapter as main thread that
handles timers and ACE_Timer_Heap holds job classes nested from
ACE_Event_Handler. And once job class gets handle_timeout notification
it starts job (thread pool).

> No, that's not correct.  You need to make sure you are
> . Activating the threads outside of handle_timeout().
Tried it and did not help - thread pool objects and working threads
where activated immidiately after service was started.

> . Not letting the queue fill up.
You mean that working thread blocks everything while waiting message
from queue?

> I recommend you read Chapter 6 and 7 of C++NPv2
> <www.cs.wustl.edu/~schmidt/ACE/book2/> for more examples of how to use
> thread pools with ACE_Task.
My favorite books along APG. :)

I'm just do not understand what thread pool (ACE_Task ) is braking and
why it should be activated before everything. It uses own queue. and
it starts as thread through global Thread Manager. After working
threads are done, the thread pool class just getting destroyed and
handle_timeout exists. The solutions is should be simple.

Thank you again.

On Aug 29, 9:49 am, schm... at dre.vanderbilt.edu (Douglas C. Schmidt)
wrote:
> Hi,
>
> >I'm using ThreadPool (Manager) sample from chapter 16.2 of APG.
> >I'm starting it as
> >ThreadPool.activate(); <- I tried different settings but it did not
> >help.
>
> BTW, *always* make sure to check the return values of any methods you
> call to make sure things are working properly.
>
> >loop
> >{
> > ThreadPool.putq(MessageBlock);
>
> Aha, so is this blocking the handle_timeout() call?  If so, that's why
> you're not getting any other timers dispatched..
>
> >}
>
> >I have to process large array on handle_timeout() so I decided to do
> >it by using thread pool.
>
> Right, but you need to make sure that you have a separate thread
> running to handle timers.
>
> >>>>> It sounds like you aren't allowing the main thread to run anymore once
> >>>>> you spawn the thread pool - hence the timer signals won't get to run.
>
> >Yes. This is what I'm thinking. I just needed simple and local thread
> >pool implementation and I was hoping ACE_Task will do the trick. But
> >it looks like ACE_Task activate() overwrites something global.
>
> No, that's not correct.  You need to make sure you are
>
> . Activating the threads outside of handle_timeout().
>
> . Not letting the queue fill up.
>
> I recommend you read Chapter 6 and 7 of C++NPv2
> <www.cs.wustl.edu/~schmidt/ACE/book2/> for more examples of how to use
> thread pools with ACE_Task.
>
> Thanks,
>
> Doug
>
> --
> Dr. Douglas C. Schmidt                       Professor and Associate Chair
> Electrical Engineering and Computer Science  TEL: (615) 343-8197
> Vanderbilt University                        WEB:www.dre.vanderbilt.edu/~schmidt
> Nashville, TN 37203                          NET: d.schm... at vanderbilt.edu




More information about the Ace-users mailing list