Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Asynch_Pseudo_Task.cpp
blob245581c6f9f347b3e63c34b600455f6cd0b0ceba
1 #include "ace/Asynch_Pseudo_Task.h"
3 #include "ace/OS_NS_errno.h"
4 #include "ace/OS_NS_signal.h"
6 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
8 ACE_Asynch_Pseudo_Task::ACE_Asynch_Pseudo_Task ()
9 : select_reactor_ (), // should be initialized before reactor_
10 reactor_ (&select_reactor_, 0) // don't delete implementation
14 ACE_Asynch_Pseudo_Task::~ACE_Asynch_Pseudo_Task ()
16 this->stop ();
19 int
20 ACE_Asynch_Pseudo_Task::start ()
22 if (this->reactor_.initialized () == 0)
23 ACELIB_ERROR_RETURN ((LM_ERROR,
24 ACE_TEXT ("%N:%l:%p\n"),
25 ACE_TEXT ("start reactor is not initialized")),
26 -1);
28 return this->activate () == -1 ? -1 : 0; // If started, return 0
31 int
32 ACE_Asynch_Pseudo_Task::stop ()
34 if (this->thr_count () == 0) // already stopped
35 return 0;
37 if (this->reactor_.end_reactor_event_loop () == -1)
38 return -1;
40 this->wait ();
41 this->reactor_.close ();
42 return 0;
45 int
46 ACE_Asynch_Pseudo_Task::svc ()
48 #if !defined (ACE_WIN32)
50 sigset_t RT_signals;
52 sigemptyset (&RT_signals);
53 for (int si = ACE_SIGRTMIN; si <= ACE_SIGRTMAX; si++)
54 sigaddset (&RT_signals, si);
56 if (ACE_OS::pthread_sigmask (SIG_BLOCK, &RT_signals, 0) != 0)
57 ACELIB_ERROR ((LM_ERROR,
58 ACE_TEXT ("Error:(%P | %t):%p\n"),
59 ACE_TEXT ("pthread_sigmask")));
60 #endif
62 reactor_.owner (ACE_Thread::self ());
63 reactor_.run_reactor_event_loop ();
65 return 0;
69 int
70 ACE_Asynch_Pseudo_Task::register_io_handler (ACE_HANDLE handle,
71 ACE_Event_Handler *handler,
72 ACE_Reactor_Mask mask,
73 int flg_suspend)
75 // Register the handler with the reactor.
76 if (-1 == this->reactor_.register_handler (handle, handler, mask))
77 return -1;
79 if (flg_suspend == 0)
80 return 0;
82 // Suspend the handle now. Enable only when the accept is issued
83 // by the application.
84 if (this->reactor_.suspend_handler (handle) == -1)
86 ACELIB_ERROR
87 ((LM_ERROR,
88 ACE_TEXT ("%N:%l:%p\n"),
89 ACE_TEXT ("register_io_handler (suspended)")));
90 this->reactor_.remove_handler (handle, ACE_Event_Handler::ALL_EVENTS_MASK
91 | ACE_Event_Handler::DONT_CALL);
92 return -1;
95 return 0;
98 int
99 ACE_Asynch_Pseudo_Task::remove_io_handler (ACE_HANDLE handle)
101 return this->reactor_.remove_handler (handle,
102 ACE_Event_Handler::ALL_EVENTS_MASK
103 | ACE_Event_Handler::DONT_CALL);
107 ACE_Asynch_Pseudo_Task::remove_io_handler (ACE_Handle_Set &set)
109 return this->reactor_.remove_handler (set, ACE_Event_Handler::ALL_EVENTS_MASK
110 | ACE_Event_Handler::DONT_CALL);
114 ACE_Asynch_Pseudo_Task::suspend_io_handler (ACE_HANDLE handle)
116 return this->reactor_.suspend_handler (handle);
120 ACE_Asynch_Pseudo_Task::resume_io_handler (ACE_HANDLE handle)
122 return this->reactor_.resume_handler (handle);
125 ACE_END_VERSIONED_NAMESPACE_DECL