Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Newbie question: ACE_Select_Reactor_T::handle_events exit because of thread id check

21 views
Skip to first unread message

yipant

unread,
Nov 16, 2009, 12:58:52 AM11/16/09
to
Hi,

First of all, I'm fairly new to ACE and hope this is the correct forum
for my questions.

In my project which uses ACE, the implementation chosen for the
ACE_Reactor is the select reactor. I'm on Mac OS X Snow Leopard
(intel).

Basically, what my code does is to create the ACE_Reactor on the main
thread, which calls ACE_Select_Reactor_T::open and assign owner_ to
ACE_Thread::self( ). However, because I would like to process the
events on a separate thread (other than the main thread), I spawn off
a new thread with a worker function that basically calls
ACE_Reactor::run_reactor_event_loop.

However, inside the run_reactor_event_loop function, one of the
condition implementation_->handle_events() checks for is that the
owner_ is equal to ACE_Thread::self(). Because we're now inside the
worker function of the newly spawned thread, the condition fails and
handle_events exits.

Forgive my ignorance but what is the reason behind the condition of
checking the thread ids? To achieve my objective of creating the
reactor on the main thread and later call run_reactor_event loop on
newly spawn threads, are there things I'm missing so that I'll be able
to do this?

Please let me know if I'm missing important details in phrasing my
question.


Douglas C. Schmidt

unread,
Nov 16, 2009, 9:49:52 AM11/16/09
to anthon...@gmail.com, ace-...@cse.wustl.edu
Hi Anthony,

>First of all, I'm fairly new to ACE and hope this is the correct forum
>for my questions.

Yes, indeed! Please make sure you fill out the appropriate problem
report form (PRF), which is in

$ACE_ROOT/PROBLEM-REPORT-FORM
$TAO_ROOT/PROBLEM-REPORT-FORM

or in

$ACE_ROOT/BUG-REPORT-FORM
$TAO_ROOT/BUG-REPORT-FORM

in older versions of ACE+TAO. Make sure to include this information
when asking any questions about ACE+TAO since otherwise we have to
"guess" what version/platform/compiler/options you've using, which is
very error-prone and slows down our responsiveness. If you don't use
the PRF, therefore, it is less likely that someone from the core
ACE+TAO developer team will be able to answer your question.
Naturally, we encourage and appreciate other members of the ACE+TAO
user community who can respond to questions that they have the answers
to.

>In my project which uses ACE, the implementation chosen for the
>ACE_Reactor is the select reactor. I'm on Mac OS X Snow Leopard
>(intel).

BTW, please make sure you're using the latest/greatest version of ACE,
which is versio 5.7.4 since the DOC group at Vanderbilt University
only provides "best effort" support for non-sponsors who are using the
latest release, as described in

http://www.dre.vanderbilt.edu/~schmidt/DOC_ROOT/ACE/docs/ACE-bug-process.html

You can download ACE 5.7.4 from

http://download.dre.vanderbilt.edu

under the heading: "Latest Micro Release Kit". If you need more
"predictable" help or need help for earlier versions of ACE+TAO+CIAO
please see

http://www.dre.vanderbilt.edu/support.html

for a list of companies that will provide you with ACE+TAO+CIAO
commercial support.

>Basically, what my code does is to create the ACE_Reactor on the main
>thread, which calls ACE_Select_Reactor_T::open and assign owner_ to
>ACE_Thread::self( ). However, because I would like to process the
>events on a separate thread (other than the main thread), I spawn off
>a new thread with a worker function that basically calls
>ACE_Reactor::run_reactor_event_loop.

Ok, that's fine.

>However, inside the run_reactor_event_loop function, one of the
>condition implementation_->handle_events() checks for is that the
>owner_ is equal to ACE_Thread::self(). Because we're now inside the
>worker function of the newly spawned thread, the condition fails and
>handle_events exits.

Yes, that's corret.

>Forgive my ignorance but what is the reason behind the condition of
>checking the thread ids?

The check is there since the ACE_Select_Reactor's event loop can only
run in one thread at a time.

>To achieve my objective of creating the
>reactor on the main thread and later call run_reactor_event loop on
>newly spawn threads, are there things I'm missing so that I'll be able
>to do this?

Sure, just call

reactor->owner (ACE_Thread::self ());

in the thread that you want to run the reactor's event loop. Please see

ACE_ROOT/tests/Reactors_Test.cpp

for an example and read chapter 4 of the C++NPv2 book
<www.cs.wustl.edu/~schmidt/ACE/book2/> for a detailed explanation of
why the ACE_Select_Reactor works like this and how other ACE Reactors
(e.g., ACE_TP_Reactor and ACE_WFMO_Reactor) differ in this respect.

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.sc...@vanderbilt.edu

yipant

unread,
Nov 16, 2009, 12:53:45 PM11/16/09
to
Thank you very much Doug. I will remember to use the problem report
form next time.
My problem was resolved with your solution. Thanks

On Nov 16, 9:49 am, schm...@dre.vanderbilt.edu (Douglas C. Schmidt)
wrote:

> http://www.dre.vanderbilt.edu/~schmidt/DOC_ROOT/ACE/docs/ACE-bug-proc...

> Nashville, TN 37203                          NET: d.schm...@vanderbilt.edu

0 new messages