Correct feature names
[ACE_TAO.git] / ACE / ace / Select_Reactor_T.h
blob1e30923f48209a730b1f9b80f69075286fc372df
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Select_Reactor_T.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 */
9 //=============================================================================
11 #ifndef ACE_SELECT_REACTOR_T_H
12 #define ACE_SELECT_REACTOR_T_H
13 #include /**/ "ace/pre.h"
15 #include "ace/Select_Reactor_Base.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 # pragma once
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "ace/Lock_Adapter_T.h"
22 #include "ace/Token.h"
24 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
27 * Hook for specializing the reactor with the concrete
28 * type, for example, select, or thread pool.
30 //@@ REACTOR_SPL_INCLUDE_FORWARD_DECL_ADD_HOOK
32 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
33 typedef ACE_Token ACE_SELECT_TOKEN;
34 #else
35 typedef ACE_Noop_Token ACE_SELECT_TOKEN;
36 #endif /* ACE_MT_SAFE && ACE_MT_SAFE != 0 */
38 /**
39 * @class ACE_Select_Reactor_T
41 * @brief An object oriented event demultiplexor and event handler
42 * dispatcher.
44 * The ACE_Select_Reactor is an object-oriented event
45 * demultiplexor and event handler dispatcher. The sources of
46 * events that the ACE_Select_Reactor waits for and dispatches
47 * includes I/O events, signals, and timer events. All public
48 * methods acquire the main ACE_Reactor_Token lock and
49 * call down to private or protected methods, which assume that
50 * the lock is held and so therefore don't (re)acquire the lock.
52 template <class ACE_SELECT_REACTOR_TOKEN>
53 class ACE_Select_Reactor_T : public ACE_Select_Reactor_Impl
55 public:
56 /// If @a disable_notify_pipe is non-0 then the reactor will
57 /// not create a notification pipe, which will save two I/O handles
58 /// but will elide the notify() feature. If @a mask_signals is
59 /// true the reactor is "signal-safe" when dispatching handlers to
60 /// signal events, whereas if @a mask_signals is false the reactor will
61 /// be more efficient, but not signal-safe (which may be perfectly
62 /// fine if your application doesn't use the reactor to handle signals).
63 ACE_Select_Reactor_T (ACE_Sig_Handler * = 0,
64 ACE_Timer_Queue * = 0,
65 int disable_notify_pipe = ACE_DISABLE_NOTIFY_PIPE_DEFAULT,
66 ACE_Reactor_Notify *notify = 0,
67 bool mask_signals = true,
68 int s_queue = ACE_SELECT_TOKEN::FIFO);
70 /// Initialize @c ACE_Select_Reactor with size @arg size.
71 /// If @arg disable_notify_pipe is non-0 then the reactor will
72 /// not create a notification pipe, which will save two I/O handles
73 /// but will elide the notification feature. If @arg mask_signals is
74 /// true the reactor is "signal-safe" when dispatching handlers to
75 /// signal events, whereas if @arg mask_signals is false the reactor will
76 /// be more efficient, but not signal-safe (which may be perfectly
77 /// fine if your application doesn't use the reactor to handle signals).
78 /**
79 * @note On Unix platforms, the size parameter should be as large as
80 * the maximum number of file descriptors allowed for a given
81 * process. This is necessary since a file descriptor is used
82 * to directly index the array of event handlers maintained by
83 * the Reactor's handler repository. Direct indexing is used
84 * for efficiency reasons.
86 ACE_Select_Reactor_T (size_t size,
87 bool restart = false,
88 ACE_Sig_Handler * = 0,
89 ACE_Timer_Queue * = 0,
90 int disable_notify_pipe = ACE_DISABLE_NOTIFY_PIPE_DEFAULT,
91 ACE_Reactor_Notify *notify = 0,
92 bool mask_signals = true,
93 int s_queue = ACE_SELECT_TOKEN::FIFO);
95 /**
96 * Initialize the @c ACE_Select_Reactor to manage
97 * @arg max_number_of_handles. If @arg restart is non-0 then the
98 * @c ACE_Reactor's @c handle_events method will be restarted
99 * automatically when @c EINTR occurs. If @arg signal_handler or
100 * @arg timer_queue are non-0 they are used as the signal handler and
101 * timer queue, respectively. If @arg disable_notify_pipe is non-0 the
102 * notification pipe is not created, thereby saving two I/O handles.
104 * @note On Unix platforms, the @a maximum_number_of_handles parameter
105 * should be as large as the maximum number of file
106 * descriptors allowed for a given process. This is necessary
107 * since a file descriptor is used to directly index the array
108 * of event handlers maintained by the Reactor's handler
109 * repository. Direct indexing is used for efficiency
110 * reasons.
112 virtual int open (size_t max_number_of_handles = DEFAULT_SIZE,
113 bool restart = false,
114 ACE_Sig_Handler * = 0,
115 ACE_Timer_Queue * = 0,
116 int disable_notify_pipe = ACE_DISABLE_NOTIFY_PIPE_DEFAULT,
117 ACE_Reactor_Notify * = 0);
119 /// Returns -1 (not used in this implementation);
120 virtual int current_info (ACE_HANDLE, size_t &size);
122 /// Use a user specified signal handler instead.
123 virtual int set_sig_handler (ACE_Sig_Handler *signal_handler);
125 /// Set a user-specified timer queue.
126 virtual int timer_queue (ACE_Timer_Queue *tq);
128 /// Return the current ACE_Timer_Queue.
129 virtual ACE_Timer_Queue *timer_queue (void) const;
131 /// Close down the select_reactor and release all of its resources.
132 virtual int close (void);
134 /// Close down the select_reactor and release all of its resources.
135 virtual ~ACE_Select_Reactor_T (void);
137 // = Event loop drivers.
140 * Returns non-zero if there are I/O events "ready" for dispatching,
141 * but does not actually dispatch the event handlers. By default,
142 * don't block while checking this, i.e., "poll".
144 virtual int work_pending (const ACE_Time_Value &max_wait_time = ACE_Time_Value::zero);
146 //@{
148 * This event loop driver that blocks for @a max_wait_time before
149 * returning. It will return earlier if timer events, I/O events,
150 * or signal events occur. Note that @a max_wait_time can be 0, in
151 * which case this method blocks indefinitely until events occur.
153 * @a max_wait_time is decremented to reflect how much time this call
154 * took. For instance, if a time value of 3 seconds is passed to
155 * handle_events and an event occurs after 2 seconds,
156 * @a max_wait_time will equal 1 second. This can be used if an
157 * application wishes to handle events for some fixed amount of
158 * time.
160 * Returns the total number of I/O and Timer ACE_Event_Handler's
161 * that were dispatched, 0 if the @a max_wait_time elapsed without
162 * dispatching any handlers, or -1 if something goes wrong.
164 * Current alertable_handle_events() is identical to
165 * handle_events().
167 virtual int handle_events (ACE_Time_Value *max_wait_time = 0);
168 virtual int alertable_handle_events (ACE_Time_Value *max_wait_time = 0);
169 //@}
171 //@{
173 * This method is just like the one above, except the
174 * @a max_wait_time value is a reference and can therefore never be
175 * NULL.
177 * Current <alertable_handle_events> is identical to
178 * <handle_events>.
180 virtual int handle_events (ACE_Time_Value &max_wait_time);
181 virtual int alertable_handle_events (ACE_Time_Value &max_wait_time);
182 //@}
184 // = Event handling control.
187 * Return the status of Reactor. If this function returns 0, the reactor is
188 * actively handling events. If it returns non-zero, <handling_events> and
189 * <handle_alertable_events> return -1 immediately.
191 virtual int deactivated (void);
194 * Control whether the Reactor will handle any more incoming events or not.
195 * If @a do_stop == 1, the Reactor will be disabled. By default, a reactor
196 * is in active state and can be deactivated/reactived as wish.
198 virtual void deactivate (int do_stop);
200 // = Register and remove ACE_Event_Handlers.
202 * Register a @a eh with a particular @a mask. Note that the
203 * <Select_Reactor> will call ACE_Event_Handler::get_handle() to
204 * extract the underlying I/O handle.
206 virtual int register_handler (ACE_Event_Handler *eh,
207 ACE_Reactor_Mask mask);
210 * Register a @a eh with a particular @a mask. Note that since the
211 * @a handle is given the Select_Reactor will *not* call
212 * ACE_Event_Handler::get_handle() to extract the underlying I/O
213 * handle.
215 virtual int register_handler (ACE_HANDLE handle,
216 ACE_Event_Handler *eh,
217 ACE_Reactor_Mask mask);
219 #if defined (ACE_WIN32)
220 // Originally this interface was available for all platforms, but
221 // because ACE_HANDLE is an int on non-Win32 platforms, compilers
222 // are not able to tell the difference between
223 // register_handler(ACE_Event_Handler*,ACE_Reactor_Mask) and
224 // register_handler(ACE_Event_Handler*,ACE_HANDLE). Therefore, we
225 // have restricted this method to Win32 only.
227 /// Not implemented.
228 virtual int register_handler (ACE_Event_Handler *event_handler,
229 ACE_HANDLE event_handle = ACE_INVALID_HANDLE);
230 #endif /* ACE_WIN32 */
232 /// Not implemented.
233 virtual int register_handler (ACE_HANDLE event_handle,
234 ACE_HANDLE io_handle,
235 ACE_Event_Handler *event_handler,
236 ACE_Reactor_Mask mask);
238 /// Register @a eh with all the @a handles in the <Handle_Set>.
239 virtual int register_handler (const ACE_Handle_Set &handles,
240 ACE_Event_Handler *eh,
241 ACE_Reactor_Mask mask);
244 * Register @a new_sh to handle the signal @a signum using the
245 * @a new_disp. Returns the @a old_sh that was previously registered
246 * (if any), along with the @a old_disp of the signal handler.
248 virtual int register_handler (int signum,
249 ACE_Event_Handler *new_sh,
250 ACE_Sig_Action *new_disp = 0,
251 ACE_Event_Handler **old_sh = 0,
252 ACE_Sig_Action *old_disp = 0);
254 /// Registers @a new_sh to handle a set of signals @a sigset using the
255 /// @a new_disp.
256 virtual int register_handler (const ACE_Sig_Set &sigset,
257 ACE_Event_Handler *new_sh,
258 ACE_Sig_Action *new_disp = 0);
261 * Removes the @a mask binding of @a eh from the Select_Reactor. If
262 * there are no more bindings for this @a eh then it is removed from
263 * the Select_Reactor. Note that the Select_Reactor will call
264 * <ACE_Event_Handler::get_handle> to extract the underlying I/O
265 * handle.
267 virtual int remove_handler (ACE_Event_Handler *eh,
268 ACE_Reactor_Mask mask);
271 * Removes the @a mask bind of Event_Handler whose handle is
272 * @a handle from the Select_Reactor. If there are no more bindings
273 * for this @a eh then it is removed from the Select_Reactor.
275 virtual int remove_handler (ACE_HANDLE handle,
276 ACE_Reactor_Mask);
279 * Removes all the @a mask bindings for handles in the @a handle_set
280 * bind of Event_Handler. If there are no more bindings for any
281 * of these handlers then they are removed from the Select_Reactor.
283 virtual int remove_handler (const ACE_Handle_Set &handle_set,
284 ACE_Reactor_Mask);
287 * Remove the ACE_Event_Handler currently associated with @a signum.
288 * @a sigkey is ignored in this implementation since there is only
289 * one instance of a signal handler. Install the new disposition
290 * (if given) and return the previous disposition (if desired by the
291 * caller). Returns 0 on success and -1 if @a signum is invalid.
293 virtual int remove_handler (int signum,
294 ACE_Sig_Action *new_disp,
295 ACE_Sig_Action *old_disp = 0,
296 int sigkey = -1);
298 /// Calls <remove_handler> for every signal in @a sigset.
299 virtual int remove_handler (const ACE_Sig_Set &sigset);
301 // = Suspend and resume Handlers.
303 /// Temporarily suspend the <Event_Handler> associated with @a eh.
304 virtual int suspend_handler (ACE_Event_Handler *eh);
306 /// Temporarily suspend the Event_Handler associated with @a handle.
307 virtual int suspend_handler (ACE_HANDLE handle);
309 /// Suspend all @a handles in handle set temporarily.
310 virtual int suspend_handler (const ACE_Handle_Set &handles);
312 /// Suspend all the <Event_Handlers> in the Select_Reactor.
313 virtual int suspend_handlers (void);
315 /// Resume a temporarily suspend Event_Handler associated with
316 /// @a eh.
317 virtual int resume_handler (ACE_Event_Handler *eh);
319 /// Resume a temporarily suspended Event_Handler associated with
320 /// @a handle.
321 virtual int resume_handler (ACE_HANDLE handle);
323 /// Resume all @a handles in handle set.
324 virtual int resume_handler (const ACE_Handle_Set &handles);
326 /// Resume all the <Event_Handlers> in the Select_Reactor.
327 virtual int resume_handlers (void);
330 * Return true if we any event associations were made by the reactor
331 * for the handles that it waits on, false otherwise. Since the
332 * Select_Reactor does not do any event associations, this function
333 * always return false.
335 virtual bool uses_event_associations (void);
337 // = Timer management.
339 * Schedule an ACE_Event_Handler that will expire after an amount
340 * of time. The return value of this method, a timer_id value,
341 * uniquely identifies the event_handler in the ACE_Reactor's
342 * internal list of timers.
343 * This timer_id value can be used to cancel the timer
344 * with the cancel_timer() call.
346 * @see cancel_timer()
347 * @see reset_timer_interval()
349 * @param event_handler Event handler to schedule on reactor
350 * @param arg Argument passed to the handle_timeout() method of event_handler
351 * @param delay Time interval after which the timer will expire
352 * @param interval Time interval after which the timer will be automatically
353 * rescheduled
354 * @return -1 on failure, a timer_id value on success
356 virtual long schedule_timer (ACE_Event_Handler * event_handler,
357 const void *arg,
358 const ACE_Time_Value &delay,
359 const ACE_Time_Value &interval = ACE_Time_Value::zero);
362 * Resets the interval of the timer represented by @a timer_id to
363 * @a interval, which is specified in relative time to the current
364 * <gettimeofday>. If @a interval is equal to
365 * ACE_Time_Value::zero, the timer will become a non-rescheduling
366 * timer. Returns 0 if successful, -1 if not.
368 virtual int reset_timer_interval (long timer_id,
369 const ACE_Time_Value &interval);
372 * Cancel all <event_handlers> that match the address of
373 * @a event_handler. If @a dont_call_handle_close is 0 then the
374 * <handle_close> method of @a event_handler will be invoked.
375 * Returns number of handler's cancelled.
377 virtual int cancel_timer (ACE_Event_Handler *event_handler,
378 int dont_call_handle_close = 1);
381 * Cancel the single ACE_Event_Handler that matches the @a timer_id
382 * value (which was returned from the <schedule> method). If arg is
383 * non-NULL then it will be set to point to the ``magic cookie''
384 * argument passed in when the Event_Handler was registered. This
385 * makes it possible to free up the memory and avoid memory leaks.
386 * If @a dont_call_handle_close is 0 then the <handle_close> method
387 * of <event_handler> will be invoked. Returns 1 if cancellation
388 * succeeded and 0 if the @a timer_id wasn't found.
390 virtual int cancel_timer (long timer_id,
391 const void **arg = 0,
392 int dont_call_handle_close = 1);
394 // = High-level Event_Handler scheduling operations
396 /// ADD the dispatch MASK "bit" bound with the @a eh and the @a mask.
397 virtual int schedule_wakeup (ACE_Event_Handler *eh,
398 ACE_Reactor_Mask mask);
400 /// ADD the dispatch MASK "bit" bound with the @a handle and the @a mask.
401 virtual int schedule_wakeup (ACE_HANDLE handle,
402 ACE_Reactor_Mask mask);
404 /// CLR the dispatch MASK "bit" bound with the @a eh and the @a mask.
405 virtual int cancel_wakeup (ACE_Event_Handler *eh,
406 ACE_Reactor_Mask mask);
408 /// CLR the dispatch MASK "bit" bound with the @a handle and the @a mask.
409 virtual int cancel_wakeup (ACE_HANDLE handle,
410 ACE_Reactor_Mask mask);
412 // = Notification methods.
414 * Called by a thread when it wants to unblock the Select_Reactor.
415 * This wakeups the <ACE_Select_Reactor> if currently blocked in
416 * <select>/<poll>. Pass over both the Event_Handler *and* the
417 * @a mask to allow the caller to dictate which <Event_Handler>
418 * method the <Select_Reactor> will invoke. The ACE_Time_Value
419 * indicates how long to blocking trying to notify the
420 * <Select_Reactor>. If @a timeout == 0, the caller will block until
421 * action is possible, else will wait until the relative time
422 * specified in *@a timeout elapses).
424 virtual int notify (ACE_Event_Handler * = 0,
425 ACE_Reactor_Mask = ACE_Event_Handler::EXCEPT_MASK,
426 ACE_Time_Value * = 0);
429 * Set the maximum number of times that the
430 * ACE_Select_Reactor_Notify::handle_input() method will iterate and
431 * dispatch the ACE_Event_Handlers that are passed in via the
432 * notify pipe before breaking out of its recv loop. By default,
433 * this is set to -1, which means "iterate until the pipe is empty."
434 * Setting this to a value like "1 or 2" will increase "fairness"
435 * (and thus prevent starvation) at the expense of slightly higher
436 * dispatching overhead.
438 virtual void max_notify_iterations (int);
441 * Get the maximum number of times that the
442 * ACE_Select_Reactor_Notify::handle_input() method will iterate and
443 * dispatch the ACE_Event_Handlers that are passed in via the
444 * notify pipe before breaking out of its recv loop.
446 virtual int max_notify_iterations (void);
448 /// Get the existing restart value.
449 virtual bool restart (void);
451 /// Set a new value for restart and return the original value.
452 virtual bool restart (bool r);
454 /// Set position that the main ACE_Select_Reactor thread is requeued in the
455 /// list of waiters during a <notify> callback.
456 virtual void requeue_position (int);
458 /// Get position that the main ACE_Select_Reactor thread is requeued in the
459 /// list of waiters during a <notify> callback.
460 virtual int requeue_position (void);
462 // = Low-level wait_set mask manipulation methods.
463 /// GET/SET/ADD/CLR the dispatch mask "bit" bound with the @a eh and
464 /// @a mask.
465 virtual int mask_ops (ACE_Event_Handler *eh,
466 ACE_Reactor_Mask mask,
467 int ops);
469 /// GET/SET/ADD/CLR the dispatch MASK "bit" bound with the @a handle
470 /// and @a mask.
471 virtual int mask_ops (ACE_HANDLE handle,
472 ACE_Reactor_Mask mask,
473 int ops);
475 // = Low-level ready_set mask manipulation methods.
476 /// GET/SET/ADD/CLR the ready "bit" bound with the @a eh and @a mask.
477 virtual int ready_ops (ACE_Event_Handler *eh,
478 ACE_Reactor_Mask mask,
479 int ops);
481 /// GET/SET/ADD/CLR the ready "bit" bound with the @a handle and @a mask.
482 virtual int ready_ops (ACE_HANDLE handle,
483 ACE_Reactor_Mask,
484 int ops);
486 /// Wake up all threads in waiting in the event loop
487 virtual void wakeup_all_threads (void);
489 // = Only the owner thread can perform a <handle_events>.
491 /// Set the new owner of the thread and return the old owner.
492 virtual int owner (ACE_thread_t n_id, ACE_thread_t *o_id = 0);
494 /// Return the current owner of the thread.
495 virtual int owner (ACE_thread_t *);
497 // = Miscellaneous Handler operations.
500 * Return the Event_Handler associated with @a handle. Return 0 if
501 * @a handle is not registered.
503 virtual ACE_Event_Handler *find_handler (ACE_HANDLE handle);
506 * Check to see if @a handle is associated with a valid Event_Handler
507 * bound to @a mask. Return the @a eh associated with this @a handler
508 * if @a eh != 0.
510 virtual int handler (ACE_HANDLE handle,
511 ACE_Reactor_Mask mask,
512 ACE_Event_Handler **eh = 0);
515 * Check to see if @a signum is associated with a valid Event_Handler
516 * bound to a signal. Return the @a eh associated with this
517 * handler if @a eh != 0.
519 virtual int handler (int signum,
520 ACE_Event_Handler ** = 0);
522 /// Returns true if we've been successfully initialized, else false.
523 virtual bool initialized (void);
525 /// Returns the current size of the Reactor's internal descriptor
526 /// table.
527 virtual size_t size (void) const;
530 * Returns a reference to the ACE_Reactor_Token that is
531 * used to serialize the internal processing logic.
532 * This can be useful for situations where you need to avoid
533 * deadlock efficiently when ACE_Event_Handlers are used in
534 * multiple threads.
536 virtual ACE_Lock &lock (void);
538 /// Dump the state of an object.
539 virtual void dump (void) const;
541 /// Declare the dynamic allocation hooks.
542 ACE_ALLOC_HOOK_DECLARE;
544 protected:
545 // = Internal methods that do the actual work.
547 // All of these methods assume that the token
548 // lock is held by the public methods that call down to them.
550 /// Do the work of actually binding the @a handle and @a eh with the
551 /// @a mask.
552 virtual int register_handler_i (ACE_HANDLE handle,
553 ACE_Event_Handler *eh,
554 ACE_Reactor_Mask mask);
556 /// Register a set of @a handles.
557 virtual int register_handler_i (const ACE_Handle_Set &handles,
558 ACE_Event_Handler *handler,
559 ACE_Reactor_Mask mask);
561 /// Do the work of actually unbinding the @a handle and @a eh with the
562 /// @a mask.
563 virtual int remove_handler_i (ACE_HANDLE handle,
564 ACE_Reactor_Mask);
566 /// Remove a set of @a handles.
567 virtual int remove_handler_i (const ACE_Handle_Set &handles,
568 ACE_Reactor_Mask);
570 /// Suspend the <Event_Handler> associated with @a handle
571 virtual int suspend_i (ACE_HANDLE handle);
573 /// Check to see if the <Event_Handler> associated with @a handle is
574 /// suspended. Returns 0 if not, 1 if so.
575 virtual int is_suspended_i (ACE_HANDLE handle);
577 /// Resume the <Event_Handler> associated with @a handle
578 virtual int resume_i (ACE_HANDLE handle);
580 /// Implement the public handler method.
581 virtual ACE_Event_Handler *find_handler_i (ACE_HANDLE handle);
583 /// Implement the public handler method.
584 virtual int handler_i (ACE_HANDLE handle,
585 ACE_Reactor_Mask,
586 ACE_Event_Handler ** = 0);
588 /// Implement the public handler method.
589 virtual int handler_i (int signum, ACE_Event_Handler ** = 0);
592 * Check if there are any HANDLEs enabled in the <ready_set_>, and
593 * if so, update the @a handle_set and return the number ready. If
594 * there aren't any HANDLEs enabled return 0.
596 virtual int any_ready (ACE_Select_Reactor_Handle_Set &handle_set);
598 /// Implement the <any_ready> method, assuming that the Sig_Guard is
599 /// being held
600 virtual int any_ready_i (ACE_Select_Reactor_Handle_Set &handle_set);
602 /// Take corrective action when errors occur.
603 virtual int handle_error (void);
605 /// Make sure the handles are all valid.
606 virtual int check_handles (void);
608 /// Wait for events to occur.
609 virtual int wait_for_multiple_events (ACE_Select_Reactor_Handle_Set &,
610 ACE_Time_Value *);
612 // = Dispatching methods.
615 * Template Method that dispatches ACE_Event_Handlers for time
616 * events, I/O events, and signal events. Returns the total number
617 * of ACE_Event_Handlers that were dispatched or -1 if something
618 * goes wrong.
620 virtual int dispatch (int nfound,
621 ACE_Select_Reactor_Handle_Set &);
624 * Dispatch all timer handlers that have expired. Returns -1 if the
625 * state of the <wait_set_> has changed, else 0.
626 * <number_dispatched> is set to the number of timer handlers
627 * dispatched.
629 virtual int dispatch_timer_handlers (int &number_dispatched);
632 * Dispatch any notification handlers. Returns -1 if the state of
633 * the <wait_set_> has changed, else returns number of handlers
634 * notified.
636 virtual int dispatch_notification_handlers (ACE_Select_Reactor_Handle_Set &dispatch_set,
637 int &number_of_active_handles,
638 int &number_of_handlers_dispatched);
641 * Dispatch all the input/output/except handlers that are enabled in
642 * the @a dispatch_set. Updates @a number_of_active_handles and
643 * @a number_of_handlers_dispatched according to the behavior of the
644 * number Returns -1 if the state of the <wait_set_> has changed,
645 * else 0.
647 virtual int dispatch_io_handlers (ACE_Select_Reactor_Handle_Set &dispatch_set,
648 int &number_of_active_handles,
649 int &number_of_handlers_dispatched);
652 * Factors the dispatching of an io handle set (each WRITE, EXCEPT
653 * or READ set of handles). It updates the
654 * @a number_of_handlers_dispatched and invokes this->notify_handle
655 * for all the handles in <dispatch_set> using the @a mask,
656 * <ready_set> and @a callback parameters. Must return -1 if
657 * this->state_changed otherwise it must return 0.
659 virtual int dispatch_io_set (int number_of_active_handles,
660 int &number_of_handlers_dispatched,
661 int mask,
662 ACE_Handle_Set& dispatch_mask,
663 ACE_Handle_Set& ready_mask,
664 ACE_EH_PTMF callback);
666 /// Notify the appropriate @a callback in the context of the @a eh
667 /// associated with @a handle that a particular event has occurred.
668 virtual void notify_handle (ACE_HANDLE handle,
669 ACE_Reactor_Mask mask,
670 ACE_Handle_Set &,
671 ACE_Event_Handler *eh,
672 ACE_EH_PTMF callback);
674 /// Enqueue ourselves into the list of waiting threads at the
675 /// appropriate point specified by <requeue_position_>.
676 virtual void renew (void);
678 /// Synchronization token for the MT_SAFE ACE_Select_Reactor.
679 ACE_SELECT_REACTOR_TOKEN token_;
681 /// Adapter used to return internal lock to outside world.
682 ACE_Lock_Adapter<ACE_SELECT_REACTOR_TOKEN> lock_adapter_;
684 /// Release the token lock when a Win32 structured exception occurs.
685 int release_token (void);
687 /// Stops the VC++ compiler from bitching about exceptions and destructors
688 int handle_events_i (ACE_Time_Value *max_wait_time = 0);
690 /// This flag is used to keep track of whether we are actively handling
691 /// events or not.
692 sig_atomic_t deactivated_;
694 private:
695 /// Deny access since member-wise won't work...
696 ACE_UNIMPLEMENTED_FUNC (ACE_Select_Reactor_T (const ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN> &))
697 ACE_UNIMPLEMENTED_FUNC (ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN> &operator= (const ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN> &) )
700 ACE_END_VERSIONED_NAMESPACE_DECL
702 #if defined (__ACE_INLINE__)
703 #include "ace/Select_Reactor_T.inl"
704 #endif /* __ACE_INLINE__ */
706 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
707 #include "ace/Select_Reactor_T.cpp"
708 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
710 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
711 #pragma implementation ("Select_Reactor_T.cpp")
712 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
714 #include /**/ "ace/post.h"
715 #endif /* ACE_SELECT_REACTOR_T_H */