Thread owner for handling Reactor's events

Thread owner for handling Reactor's events

Post by bdr » Tue, 26 Oct 2004 00:04:18


Hello there

I'm having trouble using the ACE_Reactor when events are being handled
in a new thread on Linux. On Windows it, however, works fine.

What I'm trying to do is to spawn a new thread for handling events in
the ACE_Reactor. If, however, I call
Reactor::instance()->handle_events() in the new thread it starts
returning -1 on Linux. On Windows it returns 1.

To quickly illustrate this problem Example 6 in the ACE-tutorial.pdf
can be used. If "while(1) Reactor::instance()->handle_events();" is
put into an ACE_Task's svc() function instead of the main-function
then handle_events() starts returning -1.

//This is Example 6 (works on both Win32 and Linux)
int main(int argc, char* argv[])
{
ACE_INET_Addr addr(10101);
Acceptor myacceptor(addr,Reactor::instance());
while(1) Reactor::instance()->handle_events();
return 0;
}

//This is what I'm trying to do (only works on Win32)
int main(int argc, char* argv[])
{
ACE_INET_Addr addr(10101);
Acceptor myacceptor(addr,Reactor::instance());
ReactorEventTask* pTask = new ReactorEventTask();
pTask->open(0);//ReactorEventTask::svc() loops the
Reactor::instance()->handle_events();
char c;
cin >> c;
return 0;
}

Kind regards

Bjoern

Example 6 with the above modification:
http://www.yqcomputer.com/

ACE-tutorial:
http://www.yqcomputer.com/ ~schmidt/PDF/ACE-tutorial.pdf