1
// EC_exec.cpp,v 1.1 2003/08/05 18:59:46 edwardgt Exp
4
#include "ace/Timer_Queue.h"
5
#include "ace/Reactor.h"
7
//=================================================================
9
MyImpl::timeout_Handler::timeout_Handler (MyImpl::EC_exec_i *cb)
16
this->reactor (new ACE_Reactor);
19
MyImpl::timeout_Handler::~timeout_Handler ()
21
delete this->reactor ();
26
MyImpl::timeout_Handler::open ()
28
return this->activate ();
32
MyImpl::timeout_Handler::close ()
35
this->reactor ()->notify ();
37
ACE_DEBUG ((LM_DEBUG, "Waiting\n"));
42
MyImpl::timeout_Handler::start (CORBA::Long hertz)
44
if (hertz == 0 || this->active_ != 0) // Not valid
47
long usec = 1000000 / hertz;
49
this->tid_ = this->reactor ()->schedule_timer (this,
51
ACE_Time_Value (0, usec),
52
ACE_Time_Value (0, usec));
59
MyImpl::timeout_Handler::stop (void)
61
if (this->active_ == 0) // Not valid.
64
this->reactor ()->cancel_timer (this);
71
MyImpl::timeout_Handler::active (void)
77
MyImpl::timeout_Handler::handle_close (ACE_HANDLE handle,
78
ACE_Reactor_Mask close_mask)
81
ACE_TEXT ("[%x] handle = %d, close_mask = %d\n"),
90
MyImpl::timeout_Handler::handle_timeout (const ACE_Time_Value &,
93
this->pulse_callback_->pulse ();
95
// ACE_DEBUG ((LM_DEBUG,
96
// ACE_TEXT ("[%x] with count #%05d timed out at %d.%d!\n"),
105
MyImpl::timeout_Handler::svc (void)
107
this->reactor ()->owner (ACE_OS::thr_self ());
110
this->reactor ()->handle_events ();
115
//=================================================================
117
MyImpl::EC_exec_i::EC_exec_i ()
124
MyImpl::EC_exec_i::EC_exec_i (CORBA::Long hz)
130
MyImpl::EC_exec_i::~EC_exec_i ()
135
MyImpl::EC_exec_i::hertz (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
136
ACE_THROW_SPEC ((CORBA::SystemException))
142
MyImpl::EC_exec_i::hertz (CORBA::Long hertz
143
ACE_ENV_ARG_DECL_NOT_USED)
144
ACE_THROW_SPEC ((CORBA::SystemException))
146
this->hertz_ = hertz;
149
// Operations from supported interface(s)
152
MyImpl::EC_exec_i::start (ACE_ENV_SINGLE_ARG_DECL)
153
ACE_THROW_SPEC ((CORBA::SystemException))
155
if (this->hertz_ == 0 || this->pulser_.active())
156
ACE_THROW (CORBA::BAD_INV_ORDER ());
158
// @@ Start the rate generator
159
this->pulser_.start (this->hertz_);
163
MyImpl::EC_exec_i::stop (ACE_ENV_SINGLE_ARG_DECL)
164
ACE_THROW_SPEC ((CORBA::SystemException))
166
if (! this->pulser_.active ())
167
ACE_THROW (CORBA::BAD_INV_ORDER ());
169
// @@ stop the rate generator
170
this->pulser_.stop ();
174
MyImpl::EC_exec_i::active (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
175
ACE_THROW_SPEC ((CORBA::SystemException))
177
return this->pulser_.active ();
180
// Operations from Components::SessionComponent
183
MyImpl::EC_exec_i::set_session_context (Components::SessionContext_ptr ctx
184
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
185
ACE_THROW_SPEC ((CORBA::SystemException,
186
Components::CCMException))
188
ACE_DEBUG ((LM_DEBUG, "MyImpl::EC_exec_i::set_session_context\n"));
191
BasicSP::CCM_EC_Context::_narrow (ctx
192
ACE_ENV_ARG_PARAMETER);
195
if (CORBA::is_nil (this->context_.in ()))
196
ACE_THROW (CORBA::INTERNAL ());
197
// Urm, we actually discard exceptions thown from this operation.
202
MyImpl::EC_exec_i::ccm_activate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
203
ACE_THROW_SPEC ((CORBA::SystemException,
204
Components::CCMException))
206
ACE_DEBUG ((LM_DEBUG, "MyImpl::EC_exec_i::ccm_activate\n"));
208
this->pulser_.open ();
212
MyImpl::EC_exec_i::ccm_passivate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
213
ACE_THROW_SPEC ((CORBA::SystemException,
214
Components::CCMException))
216
ACE_DEBUG ((LM_DEBUG, "MyImpl::EC_exec_i::ccm_passivate\n"));
217
this->pulser_.close ();
221
MyImpl::EC_exec_i::ccm_remove (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
222
ACE_THROW_SPEC ((CORBA::SystemException,
223
Components::CCMException))
225
ACE_DEBUG ((LM_DEBUG, "MyImpl::EC_exec_i::ccm_remove\n"));
229
MyImpl::EC_exec_i::pulse (void)
233
ACE_DEBUG ((LM_DEBUG,
234
ACE_TEXT ("Pushing BasicSP::TimeOut event!\n")));
236
BasicSP::TimeOut_var ev = new OBV_BasicSP::TimeOut ();
238
this->context_->push_timeout (ev.in ()
239
ACE_ENV_ARG_PARAMETER);
249
MyImpl::ECHome_exec_i::ECHome_exec_i ()
253
MyImpl::ECHome_exec_i::~ECHome_exec_i ()
257
::Components::EnterpriseComponent_ptr
258
MyImpl::ECHome_exec_i::new_EC (CORBA::Long hertz
260
ACE_THROW_SPEC ((CORBA::SystemException,
261
Components::CCMException))
263
return new MyImpl::EC_exec_i (hertz);
266
::Components::EnterpriseComponent_ptr
267
MyImpl::ECHome_exec_i::create (ACE_ENV_SINGLE_ARG_DECL)
268
ACE_THROW_SPEC ((CORBA::SystemException,
269
Components::CCMException))
271
return new MyImpl::EC_exec_i ();
275
extern "C" EC_EXEC_Export ::Components::HomeExecutorBase_ptr
276
createECHome_Impl (void)
278
return new MyImpl::ECHome_exec_i ();