Select_Reactor_T.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Select_Reactor_T.h
00006  *
00007  *  Select_Reactor_T.h,v 4.50 2006/02/10 10:39:07 jwillemsen Exp
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef ACE_SELECT_REACTOR_T_H
00014 #define ACE_SELECT_REACTOR_T_H
00015 #include /**/ "ace/pre.h"
00016 
00017 #include "ace/Select_Reactor_Base.h"
00018 
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 # pragma once
00021 #endif /* ACE_LACKS_PRAGMA_ONCE */
00022 
00023 #include "ace/Lock_Adapter_T.h"
00024 #include "ace/Token.h"
00025 
00026 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00027 
00028 /*
00029  * Hook for specializing the reactor with the concrete
00030  * type, for example, select, or thread pool.
00031  */
00032 //@@ REACTOR_SPL_INCLUDE_FORWARD_DECL_ADD_HOOK
00033 
00034 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00035 typedef ACE_Token ACE_SELECT_TOKEN;
00036 #else
00037 typedef ACE_Noop_Token ACE_SELECT_TOKEN;
00038 #endif /* ACE_MT_SAFE && ACE_MT_SAFE != 0 */
00039 
00040 /**
00041  * @class ACE_Select_Reactor_T
00042  *
00043  * @brief An object oriented event demultiplexor and event handler
00044  * dispatcher.
00045  *
00046  * The ACE_Select_Reactor is an object-oriented event
00047  * demultiplexor and event handler dispatcher.  The sources of
00048  * events that the ACE_Select_Reactor waits for and dispatches
00049  * includes I/O events, signals, and timer events.  All public
00050  * methods acquire the main ACE_Reactor_Token lock and
00051  * call down to private or protected methods, which assume that
00052  * the lock is held and so therefore don't (re)acquire the lock.
00053  */
00054 template <class ACE_SELECT_REACTOR_TOKEN>
00055 class ACE_Select_Reactor_T : public ACE_Select_Reactor_Impl
00056 {
00057 public:
00058 
00059   // = Initialization and termination methods.
00060 
00061   /// If <disable_notify_pipe> is non-0 then the reactor will
00062   /// not create a notification pipe, which will save two I/O handles
00063   /// but will elide the <notify()> feature.  If <mask_signals> is
00064   /// 1 the reactor is "signal-safe" when dispatching handlers to
00065   /// signal events, whereas if <mask_signals> is 0 the reactor will
00066   /// be more efficient, but not signal-safe (which may be perfectly
00067   /// fine if your application doesn't use the reactor to handle signals).
00068   ACE_Select_Reactor_T (ACE_Sig_Handler * = 0,
00069                         ACE_Timer_Queue * = 0,
00070                         int disable_notify_pipe = 0,
00071                         ACE_Reactor_Notify *notify = 0,
00072                         int mask_signals = 1,
00073                         int s_queue = ACE_SELECT_TOKEN::FIFO);
00074 
00075   /// Initialize @c ACE_Select_Reactor with size @arg size.
00076   /// If @arg disable_notify_pipe is non-0 then the reactor will
00077   /// not create a notification pipe, which will save two I/O handles
00078   /// but will elide the notification feature.  If @arg mask_signals is
00079   /// 1 the reactor is "signal-safe" when dispatching handlers to
00080   /// signal events, whereas if @arg mask_signals is 0 the reactor will
00081   /// be more efficient, but not signal-safe (which may be perfectly
00082   /// fine if your application doesn't use the reactor to handle signals).
00083   /**
00084    * @note On Unix platforms, the size parameter should be as large as
00085    *       the maximum number of file descriptors allowed for a given
00086    *       process.  This is necessary since a file descriptor is used
00087    *       to directly index the array of event handlers maintained by
00088    *       the Reactor's handler repository.  Direct indexing is used
00089    *       for efficiency reasons.
00090    */
00091   ACE_Select_Reactor_T (size_t size,
00092                         int restart = 0,
00093                         ACE_Sig_Handler * = 0,
00094                         ACE_Timer_Queue * = 0,
00095                         int disable_notify_pipe = 0,
00096                         ACE_Reactor_Notify *notify = 0,
00097                         int mask_signals = 1,
00098                         int s_queue = ACE_SELECT_TOKEN::FIFO);
00099 
00100   /**
00101    * Initialize the @c ACE_Select_Reactor to manage
00102    * @arg max_number_of_handles.  If @arg restart is non-0 then the
00103    * @c ACE_Reactor's @c handle_events method will be restarted
00104    * automatically when @c EINTR occurs.  If @arg signal_handler or
00105    * @arg timer_queue are non-0 they are used as the signal handler and
00106    * timer queue, respectively.  If @arg disable_notify_pipe is non-0 the
00107    * notification pipe is not created, thereby saving two I/O handles.
00108    *
00109    * @note On Unix platforms, the maximum_number_of_handles parameter
00110    *       should be as large as the maximum number of file
00111    *       descriptors allowed for a given process.  This is necessary
00112    *       since a file descriptor is used to directly index the array
00113    *       of event handlers maintained by the Reactor's handler
00114    *       repository.  Direct indexing is used for efficiency
00115    *       reasons.
00116    */
00117   virtual int open (size_t max_number_of_handles = DEFAULT_SIZE,
00118                     int restart = 0,
00119                     ACE_Sig_Handler * = 0,
00120                     ACE_Timer_Queue * = 0,
00121                     int disable_notify_pipe = 0,
00122                     ACE_Reactor_Notify * = 0);
00123 
00124   /// Returns -1 (not used in this implementation);
00125   virtual int current_info (ACE_HANDLE, size_t & /* size */);
00126 
00127   /// Use a user specified signal handler instead.
00128   virtual int set_sig_handler (ACE_Sig_Handler *signal_handler);
00129 
00130   /// Set a user-specified timer queue.
00131   virtual int timer_queue (ACE_Timer_Queue *tq);
00132 
00133   /// Return the current ACE_Timer_Queue.
00134   virtual ACE_Timer_Queue *timer_queue (void) const;
00135 
00136   /// Close down the select_reactor and release all of its resources.
00137   virtual int close (void);
00138 
00139   /// Close down the select_reactor and release all of its resources.
00140   virtual ~ACE_Select_Reactor_T (void);
00141 
00142   // = Event loop drivers.
00143 
00144   /**
00145    * Returns non-zero if there are I/O events "ready" for dispatching,
00146    * but does not actually dispatch the event handlers.  By default,
00147    * don't block while checking this, i.e., "poll".
00148    */
00149   virtual int work_pending (const ACE_Time_Value &max_wait_time =  ACE_Time_Value::zero);
00150 
00151   /**
00152    * This event loop driver that blocks for @a max_wait_time before
00153    * returning.  It will return earlier if timer events, I/O events,
00154    * or signal events occur.  Note that @a max_wait_time can be 0, in
00155    * which case this method blocks indefinitely until events occur.
00156    *
00157    * @a max_wait_time is decremented to reflect how much time this call
00158    * took.  For instance, if a time value of 3 seconds is passed to
00159    * handle_events and an event occurs after 2 seconds,
00160    * @a max_wait_time will equal 1 second.  This can be used if an
00161    * application wishes to handle events for some fixed amount of
00162    * time.
00163    *
00164    * Returns the total number of I/O and Timer ACE_Event_Handler's
00165    * that were dispatched, 0 if the @a max_wait_time elapsed without
00166    * dispatching any handlers, or -1 if something goes wrong.
00167    *
00168    * Current <alertable_handle_events> is identical to
00169    * <handle_events>.
00170    */
00171   virtual int handle_events (ACE_Time_Value *max_wait_time = 0);
00172   virtual int alertable_handle_events (ACE_Time_Value *max_wait_time = 0);
00173 
00174   /**
00175    * This method is just like the one above, except the
00176    * @a max_wait_time value is a reference and can therefore never be
00177    * NULL.
00178    *
00179    * Current <alertable_handle_events> is identical to
00180    * <handle_events>.
00181    */
00182   virtual int handle_events (ACE_Time_Value &max_wait_time);
00183   virtual int alertable_handle_events (ACE_Time_Value &max_wait_time);
00184 
00185   // = Event handling control.
00186 
00187   /**
00188    * Return the status of Reactor.  If this function returns 0, the reactor is
00189    * actively handling events.  If it returns non-zero, <handling_events> and
00190    * <handle_alertable_events> return -1 immediately.
00191    */
00192   virtual int deactivated (void);
00193 
00194   /**
00195    * Control whether the Reactor will handle any more incoming events or not.
00196    * If <do_stop> == 1, the Reactor will be disabled.  By default, a reactor
00197    * is in active state and can be deactivated/reactived as wish.
00198    */
00199   virtual void deactivate (int do_stop);
00200 
00201   // = Register and remove ACE_Event_Handlers.
00202   /**
00203    * Register a <eh> with a particular <mask>.  Note that the
00204    * <Select_Reactor> will call <ACE_Event_Handler::get_handle> to
00205    * extract the underlying I/O handle.
00206    */
00207   virtual int register_handler (ACE_Event_Handler *eh,
00208                                 ACE_Reactor_Mask mask);
00209 
00210   /**
00211    * Register a @a eh with a particular @a mask.  Note that since the
00212    * @a handle is given the Select_Reactor will *not* call
00213    * ACE_Event_Handler::get_handle() to extract the underlying I/O
00214    * handle.
00215    */
00216   virtual int register_handler (ACE_HANDLE handle,
00217                                 ACE_Event_Handler *eh,
00218                                 ACE_Reactor_Mask mask);
00219 
00220 #if defined (ACE_WIN32)
00221 
00222   // Originally this interface was available for all platforms, but
00223   // because ACE_HANDLE is an int on non-Win32 platforms, compilers
00224   // are not able to tell the difference between
00225   // register_handler(ACE_Event_Handler*,ACE_Reactor_Mask) and
00226   // register_handler(ACE_Event_Handler*,ACE_HANDLE). Therefore, we
00227   // have restricted this method to Win32 only.
00228 
00229   /// Not implemented.
00230   virtual int register_handler (ACE_Event_Handler *event_handler,
00231                                 ACE_HANDLE event_handle = ACE_INVALID_HANDLE);
00232 
00233 #endif /* ACE_WIN32 */
00234 
00235   /// Not implemented.
00236   virtual int register_handler (ACE_HANDLE event_handle,
00237                                 ACE_HANDLE io_handle,
00238                                 ACE_Event_Handler *event_handler,
00239                                 ACE_Reactor_Mask mask);
00240 
00241   /// Register @a eh with all the @a handles in the <Handle_Set>.
00242   virtual int register_handler (const ACE_Handle_Set &handles,
00243                                 ACE_Event_Handler *eh,
00244                                 ACE_Reactor_Mask mask);
00245 
00246   /**
00247    * Register <new_sh> to handle the signal <signum> using the
00248    * <new_disp>.  Returns the <old_sh> that was previously registered
00249    * (if any), along with the <old_disp> of the signal handler.
00250    */
00251   virtual int register_handler (int signum,
00252                                 ACE_Event_Handler *new_sh,
00253                                 ACE_Sig_Action *new_disp = 0,
00254                                 ACE_Event_Handler **old_sh = 0,
00255                                 ACE_Sig_Action *old_disp = 0);
00256 
00257   /// Registers <new_sh> to handle a set of signals <sigset> using the
00258   /// <new_disp>.
00259   virtual int register_handler (const ACE_Sig_Set &sigset,
00260                                 ACE_Event_Handler *new_sh,
00261                                 ACE_Sig_Action *new_disp = 0);
00262 
00263   /**
00264    * Removes the <mask> binding of <eh> from the Select_Reactor.  If
00265    * there are no more bindings for this <eh> then it is removed from
00266    * the Select_Reactor.  Note that the Select_Reactor will call
00267    * <ACE_Event_Handler::get_handle> to extract the underlying I/O
00268    * handle.
00269    */
00270   virtual int remove_handler (ACE_Event_Handler *eh,
00271                               ACE_Reactor_Mask mask);
00272 
00273   /**
00274    * Removes the <mask> bind of <Event_Handler> whose handle is
00275    * <handle> from the Select_Reactor.  If there are no more bindings
00276    * for this <eh> then it is removed from the Select_Reactor.
00277    */
00278   virtual int remove_handler (ACE_HANDLE handle,
00279                               ACE_Reactor_Mask);
00280 
00281   /**
00282    * Removes all the <mask> bindings for handles in the <handle_set>
00283    * bind of <Event_Handler>.  If there are no more bindings for any
00284    * of these handlers then they are removed from the Select_Reactor.
00285    */
00286   virtual int remove_handler (const ACE_Handle_Set &handle_set,
00287                               ACE_Reactor_Mask);
00288 
00289   /**
00290    * Remove the ACE_Event_Handler currently associated with <signum>.
00291    * <sigkey> is ignored in this implementation since there is only
00292    * one instance of a signal handler.  Install the new disposition
00293    * (if given) and return the previous disposition (if desired by the
00294    * caller).  Returns 0 on success and -1 if <signum> is invalid.
00295    */
00296   virtual int remove_handler (int signum,
00297                               ACE_Sig_Action *new_disp,
00298                               ACE_Sig_Action *old_disp = 0,
00299                               int sigkey = -1);
00300 
00301   /// Calls <remove_handler> for every signal in <sigset>.
00302   virtual int remove_handler (const ACE_Sig_Set &sigset);
00303 
00304   // = Suspend and resume Handlers.
00305 
00306   /// Temporarily suspend the <Event_Handler> associated with <eh>.
00307   virtual int suspend_handler (ACE_Event_Handler *eh);
00308 
00309   /// Temporarily suspend the <Event_Handler> associated with <handle>.
00310   virtual int suspend_handler (ACE_HANDLE handle);
00311 
00312   /// Suspend all <handles> in handle set temporarily.
00313   virtual int suspend_handler (const ACE_Handle_Set &handles);
00314 
00315   /// Suspend all the <Event_Handlers> in the Select_Reactor.
00316   virtual int suspend_handlers (void);
00317 
00318   /// Resume a temporarily suspend <Event_Handler> associated with
00319   /// <eh>.
00320   virtual int resume_handler (ACE_Event_Handler *eh);
00321 
00322   /// Resume a temporarily suspended <Event_Handler> associated with
00323   /// <handle>.
00324   virtual int resume_handler (ACE_HANDLE handle);
00325 
00326   /// Resume all <handles> in handle set.
00327   virtual int resume_handler (const ACE_Handle_Set &handles);
00328 
00329   /// Resume all the <Event_Handlers> in the Select_Reactor.
00330   virtual int resume_handlers (void);
00331 
00332   /**
00333    * Return 1 if we any event associations were made by the reactor
00334    * for the handles that it waits on, 0 otherwise. Since the
00335    * Select_Reactor does not do any event associations, this function
00336    * always return 0.
00337    */
00338   virtual int uses_event_associations (void);
00339 
00340   // = Timer management.
00341   /**
00342    * Schedule an ACE_Event_Handler that will expire after an amount
00343    * of time.  The return value of this method, a timer_id value,
00344    * uniquely identifies the event_handler in the ACE_Reactor's
00345    * internal list of timers.
00346    * This timer_id value can be used to cancel the timer
00347    * with the cancel_timer() call.
00348    *
00349    * @see cancel_timer()
00350    * @see reset_timer_interval()
00351    *
00352    * @param event_handler  Event handler to schedule on reactor
00353    * @param arg Argument passed to the handle_timeout() method of event_handler
00354    * @param delay Time interval after which the timer will expire
00355    * @param interval Time interval after which the timer will be automatically
00356    * rescheduled
00357    * @return -1 on failure, a timer_id value on success
00358    */
00359   virtual long schedule_timer (ACE_Event_Handler * event_handler,
00360                                const void *arg,
00361                                const ACE_Time_Value &delay,
00362                                const ACE_Time_Value &interval = ACE_Time_Value::zero);
00363 
00364   /**
00365    * Resets the interval of the timer represented by <timer_id> to
00366    * <interval>, which is specified in relative time to the current
00367    * <gettimeofday>.  If <interval> is equal to
00368    * <ACE_Time_Value::zero>, the timer will become a non-rescheduling
00369    * timer.  Returns 0 if successful, -1 if not.
00370    */
00371   virtual int reset_timer_interval (long timer_id,
00372                                     const ACE_Time_Value &interval);
00373 
00374   /**
00375    * Cancel all <event_handlers> that match the address of
00376    * <event_handler>.  If <dont_call_handle_close> is 0 then the
00377    * <handle_close> method of <event_handler> will be invoked.
00378    * Returns number of handler's cancelled.
00379    */
00380   virtual int cancel_timer (ACE_Event_Handler *event_handler,
00381                             int dont_call_handle_close = 1);
00382 
00383   /**
00384    * Cancel the single ACE_Event_Handler that matches the <timer_id>
00385    * value (which was returned from the <schedule> method).  If arg is
00386    * non-NULL then it will be set to point to the ``magic cookie''
00387    * argument passed in when the <Event_Handler> was registered.  This
00388    * makes it possible to free up the memory and avoid memory leaks.
00389    * If <dont_call_handle_close> is 0 then the <handle_close> method
00390    * of <event_handler> will be invoked.  Returns 1 if cancellation
00391    * succeeded and 0 if the <timer_id> wasn't found.
00392    */
00393   virtual int cancel_timer (long timer_id,
00394                             const void **arg = 0,
00395                             int dont_call_handle_close = 1);
00396 
00397   // = High-level Event_Handler scheduling operations
00398 
00399   /// ADD the dispatch MASK "bit" bound with the <eh> and the <mask>.
00400   virtual int schedule_wakeup (ACE_Event_Handler *eh,
00401                                ACE_Reactor_Mask mask);
00402 
00403   /// ADD the dispatch MASK "bit" bound with the <handle> and the <mask>.
00404   virtual int schedule_wakeup (ACE_HANDLE handle,
00405                                ACE_Reactor_Mask mask);
00406 
00407   /// CLR the dispatch MASK "bit" bound with the <eh> and the <mask>.
00408   virtual int cancel_wakeup (ACE_Event_Handler *eh,
00409                              ACE_Reactor_Mask mask);
00410 
00411   /// CLR the dispatch MASK "bit" bound with the <handle> and the <mask>.
00412   virtual int cancel_wakeup (ACE_HANDLE handle,
00413                              ACE_Reactor_Mask mask);
00414 
00415   // = Notification methods.
00416   /**
00417    * Called by a thread when it wants to unblock the Select_Reactor.
00418    * This wakeups the <ACE_Select_Reactor> if currently blocked in
00419    * <select>/<poll>.  Pass over both the <Event_Handler> *and* the
00420    * <mask> to allow the caller to dictate which <Event_Handler>
00421    * method the <Select_Reactor> will invoke.  The <ACE_Time_Value>
00422    * indicates how long to blocking trying to notify the
00423    * <Select_Reactor>.  If <timeout> == 0, the caller will block until
00424    * action is possible, else will wait until the relative time
00425    * specified in *<timeout> elapses).
00426    */
00427   virtual int notify (ACE_Event_Handler * = 0,
00428                       ACE_Reactor_Mask = ACE_Event_Handler::EXCEPT_MASK,
00429                       ACE_Time_Value * = 0);
00430 
00431   /**
00432    * Set the maximum number of times that the
00433    * <ACE_Select_Reactor_Notify::handle_input> method will iterate and
00434    * dispatch the <ACE_Event_Handlers> that are passed in via the
00435    * notify pipe before breaking out of its <recv> loop.  By default,
00436    * this is set to -1, which means "iterate until the pipe is empty."
00437    * Setting this to a value like "1 or 2" will increase "fairness"
00438    * (and thus prevent starvation) at the expense of slightly higher
00439    * dispatching overhead.
00440    */
00441   virtual void max_notify_iterations (int);
00442 
00443   /**
00444    * Get the maximum number of times that the
00445    * <ACE_Select_Reactor_Notify::handle_input> method will iterate and
00446    * dispatch the <ACE_Event_Handlers> that are passed in via the
00447    * notify pipe before breaking out of its <recv> loop.
00448    */
00449   virtual int max_notify_iterations (void);
00450 
00451   /// Get the existing restart value.
00452   virtual int restart (void);
00453 
00454   /// Set a new value for restart and return the original value.
00455   virtual int restart (int r);
00456 
00457   /// Set position that the main ACE_Select_Reactor thread is requeued in the
00458   /// list of waiters during a <notify> callback.
00459   virtual void requeue_position (int);
00460 
00461   /// Get position that the main ACE_Select_Reactor thread is requeued in the
00462   /// list of waiters during a <notify> callback.
00463   virtual int requeue_position (void);
00464 
00465   // = Low-level wait_set mask manipulation methods.
00466   /// GET/SET/ADD/CLR the dispatch mask "bit" bound with the <eh> and
00467   /// <mask>.
00468   virtual int mask_ops (ACE_Event_Handler *eh,
00469                         ACE_Reactor_Mask mask,
00470                         int ops);
00471 
00472   /// GET/SET/ADD/CLR the dispatch MASK "bit" bound with the <handle>
00473   /// and <mask>.
00474   virtual int mask_ops (ACE_HANDLE handle,
00475                         ACE_Reactor_Mask mask,
00476                         int ops);
00477 
00478   // = Low-level ready_set mask manipulation methods.
00479   /// GET/SET/ADD/CLR the ready "bit" bound with the <eh> and <mask>.
00480   virtual int ready_ops (ACE_Event_Handler *eh,
00481                          ACE_Reactor_Mask mask,
00482                          int ops);
00483 
00484   /// GET/SET/ADD/CLR the ready "bit" bound with the <handle> and <mask>.
00485   virtual int ready_ops (ACE_HANDLE handle,
00486                          ACE_Reactor_Mask,
00487                          int ops);
00488 
00489   /// Wake up all threads in waiting in the event loop
00490   virtual void wakeup_all_threads (void);
00491 
00492   // = Only the owner thread can perform a <handle_events>.
00493 
00494   /// Set the new owner of the thread and return the old owner.
00495   virtual int owner (ACE_thread_t n_id, ACE_thread_t *o_id = 0);
00496 
00497   /// Return the current owner of the thread.
00498   virtual int owner (ACE_thread_t *);
00499 
00500   // = Miscellaneous Handler operations.
00501 
00502   /**
00503    * Return the Event_Handler associated with <handle>.  Return 0 if
00504    * <handle> is not registered.
00505    */
00506   virtual ACE_Event_Handler *find_handler (ACE_HANDLE handle);
00507 
00508   /**
00509    * Check to see if <handle> is associated with a valid Event_Handler
00510    * bound to <mask>.  Return the <eh> associated with this <handler>
00511    * if <eh> != 0.
00512    */
00513   virtual int handler (ACE_HANDLE handle,
00514                        ACE_Reactor_Mask mask,
00515                        ACE_Event_Handler **eh = 0);
00516 
00517   /**
00518    * Check to see if <signum> is associated with a valid Event_Handler
00519    * bound to a signal.  Return the <eh> associated with this
00520    * <handler> if <eh> != 0.
00521    */
00522   virtual int handler (int signum,
00523                        ACE_Event_Handler ** = 0);
00524 
00525   /// Returns true if we've been successfully initialized, else false.
00526   virtual int initialized (void);
00527 
00528   /// Returns the current size of the Reactor's internal descriptor
00529   /// table.
00530   virtual size_t size (void) const;
00531 
00532   /**
00533    * Returns a reference to the ACE_Reactor_Token that is
00534    * used to serialize the internal processing logic.
00535    * This can be useful for situations where you need to avoid
00536    * deadlock efficiently when ACE_Event_Handlers are used in
00537    * multiple threads.
00538    */
00539   virtual ACE_Lock &lock (void);
00540 
00541   /// Dump the state of an object.
00542   virtual void dump (void) const;
00543 
00544   /// Declare the dynamic allocation hooks.
00545   ACE_ALLOC_HOOK_DECLARE;
00546 
00547 protected:
00548   // = Internal methods that do the actual work.
00549 
00550   // All of these methods assume that the token
00551   // lock is held by the public methods that call down to them.
00552 
00553   /// Do the work of actually binding the <handle> and <eh> with the
00554   /// <mask>.
00555   virtual int register_handler_i (ACE_HANDLE handle,
00556                                   ACE_Event_Handler *eh,
00557                                   ACE_Reactor_Mask mask);
00558 
00559   /// Register a set of <handles>.
00560   virtual int register_handler_i (const ACE_Handle_Set &handles,
00561                                   ACE_Event_Handler *handler,
00562                                   ACE_Reactor_Mask mask);
00563 
00564   /// Do the work of actually unbinding the <handle> and <eh> with the
00565   /// <mask>.
00566   virtual int remove_handler_i (ACE_HANDLE handle,
00567                                 ACE_Reactor_Mask);
00568 
00569   /// Remove a set of <handles>.
00570   virtual int remove_handler_i (const ACE_Handle_Set &handles,
00571                                 ACE_Reactor_Mask);
00572 
00573   /// Suspend the <Event_Handler> associated with <handle>
00574   virtual int suspend_i (ACE_HANDLE handle);
00575 
00576   /// Check to see if the <Event_Handler> associated with <handle> is
00577   /// suspended. Returns 0 if not, 1 if so.
00578   virtual int is_suspended_i (ACE_HANDLE handle);
00579 
00580   /// Resume the <Event_Handler> associated with <handle>
00581   virtual int resume_i (ACE_HANDLE handle);
00582 
00583   /// Implement the public <handler> method.
00584   virtual ACE_Event_Handler *find_handler_i (ACE_HANDLE handle);
00585 
00586   /// Implement the public <handler> method.
00587   virtual int handler_i (ACE_HANDLE handle,
00588                          ACE_Reactor_Mask,
00589                          ACE_Event_Handler ** = 0);
00590 
00591   /// Implement the public <handler> method.
00592   virtual int handler_i (int signum, ACE_Event_Handler ** = 0);
00593 
00594   /**
00595    * Check if there are any HANDLEs enabled in the <ready_set_>, and
00596    * if so, update the <handle_set> and return the number ready.  If
00597    * there aren't any HANDLEs enabled return 0.
00598    */
00599   virtual int any_ready (ACE_Select_Reactor_Handle_Set &handle_set);
00600 
00601   /// Implement the <any_ready> method, assuming that the Sig_Guard is
00602   /// beign held
00603   virtual int any_ready_i (ACE_Select_Reactor_Handle_Set &handle_set);
00604 
00605   /// Take corrective action when errors occur.
00606   virtual int handle_error (void);
00607 
00608   /// Make sure the handles are all valid.
00609   virtual int check_handles (void);
00610 
00611   /// Wait for events to occur.
00612   virtual int wait_for_multiple_events (ACE_Select_Reactor_Handle_Set &,
00613                                         ACE_Time_Value *);
00614 
00615   // = Dispatching methods.
00616 
00617   /**
00618    * Template Method that dispatches ACE_Event_Handlers for time
00619    * events, I/O events, and signal events.  Returns the total number
00620    * of ACE_Event_Handlers that were dispatched or -1 if something
00621    * goes wrong.
00622    */
00623   virtual int dispatch (int nfound,
00624                         ACE_Select_Reactor_Handle_Set &);
00625 
00626   /**
00627    * Dispatch all timer handlers that have expired.  Returns -1 if the
00628    * state of the <wait_set_> has changed, else 0.
00629    * <number_dispatched> is set to the number of timer handlers
00630    * dispatched.
00631    */
00632   virtual int dispatch_timer_handlers (int &number_dispatched);
00633 
00634   /**
00635    * Dispatch any notification handlers.  Returns -1 if the state of
00636    * the <wait_set_> has changed, else returns number of handlers
00637    * notified.
00638    */
00639   virtual int dispatch_notification_handlers (ACE_Select_Reactor_Handle_Set &dispatch_set,
00640                                               int &number_of_active_handles,
00641                                               int &number_of_handlers_dispatched);
00642 
00643   /**
00644    * Dispatch all the input/output/except handlers that are enabled in
00645    * the <dispatch_set>.  Updates <number_of_active_handles> and
00646    * <number_of_handlers_dispatched> according to the behavior of the
00647    * number Returns -1 if the state of the <wait_set_> has changed,
00648    * else 0.
00649    */
00650   virtual int dispatch_io_handlers (ACE_Select_Reactor_Handle_Set &dispatch_set,
00651                                     int &number_of_active_handles,
00652                                     int &number_of_handlers_dispatched);
00653 
00654   /**
00655    * Factors the dispatching of an io handle set (each WRITE, EXCEPT
00656    * or READ set of handles).  It updates the
00657    * <number_of_handlers_dispatched> and invokes this->notify_handle
00658    * for all the handles in <dispatch_set> using the <mask>,
00659    * <ready_set> and <callback> parameters.  Must return -1 if
00660    * this->state_changed otherwise it must return 0.
00661    */
00662   virtual int dispatch_io_set (int number_of_active_handles,
00663                                int &number_of_handlers_dispatched,
00664                                int mask,
00665                                ACE_Handle_Set& dispatch_mask,
00666                                ACE_Handle_Set& ready_mask,
00667                                ACE_EH_PTMF callback);
00668 
00669   /// Notify the appropriate <callback> in the context of the <eh>
00670   /// associated with <handle> that a particular event has occurred.
00671   virtual void notify_handle (ACE_HANDLE handle,
00672                               ACE_Reactor_Mask mask,
00673                               ACE_Handle_Set &,
00674                               ACE_Event_Handler *eh,
00675                               ACE_EH_PTMF callback);
00676 
00677   /// Enqueue ourselves into the list of waiting threads at the
00678   /// appropriate point specified by <requeue_position_>.
00679   virtual void renew (void);
00680 
00681   /// Synchronization token for the MT_SAFE ACE_Select_Reactor.
00682   ACE_SELECT_REACTOR_TOKEN token_;
00683 
00684   /// Adapter used to return internal lock to outside world.
00685   ACE_Lock_Adapter<ACE_SELECT_REACTOR_TOKEN> lock_adapter_;
00686 
00687   /// Release the token lock when a Win32 structured exception occurs.
00688   int release_token (void);
00689 
00690   /// Stops the VC++ compiler from bitching about exceptions and destructors
00691   int handle_events_i (ACE_Time_Value *max_wait_time = 0);
00692 
00693   /// This flag is used to keep track of whether we are actively handling
00694   /// events or not.
00695   sig_atomic_t deactivated_;
00696 
00697 private:
00698   /// Deny access since member-wise won't work...
00699   ACE_UNIMPLEMENTED_FUNC (ACE_Select_Reactor_T (const ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN> &))
00700   ACE_UNIMPLEMENTED_FUNC (ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN> &operator=  (const ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN> &) )
00701 };
00702 
00703 ACE_END_VERSIONED_NAMESPACE_DECL
00704 
00705 #if defined (__ACE_INLINE__)
00706 #include "ace/Select_Reactor_T.inl"
00707 #endif /* __ACE_INLINE__ */
00708 
00709 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00710 #include "ace/Select_Reactor_T.cpp"
00711 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
00712 
00713 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00714 #pragma implementation ("Select_Reactor_T.cpp")
00715 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
00716 
00717 #include /**/ "ace/post.h"
00718 #endif /* ACE_SELECT_REACTOR_T_H */

Generated on Thu Nov 9 09:42:02 2006 for ACE by doxygen 1.3.6