Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Synch_Options.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //==========================================================================
00004 /**
00005  *  @file   Synch_Options.h
00006  *
00007  *  $Id: Synch_Options.h,v 1.1.1.4 2003/02/21 18:36:32 chad Exp $
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@uci.edu>
00010  */
00011 //==========================================================================
00012 
00013 #ifndef ACE_SYNCH_OPTIONS_H
00014 #define ACE_SYNCH_OPTIONS_H
00015 
00016 #include "ace/pre.h"
00017 
00018 #include "ace/ACE_export.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #include "ace/OS.h"
00025 
00026 /**
00027  * @class ACE_Synch_Options
00028  *
00029  * @brief Contains the values of options used to determine the
00030  * synchronous and asynchronous behavior.
00031  *
00032  * Values support the following behavior (TV == "timeout"
00033  * and UR == "use ACE_Reactor"):
00034  *
00035  * <CODE>
00036  * | Parameters     | Description
00037  * |
00038  * |TV   |  UR      |
00039  * |-----|----------|-------------------------------
00040  * |                |
00041  * |NULL | yes      | infinite timeout (using ACE_Reactor)
00042  * |                |
00043  * |time | yes      | try asynch transaction for
00044  * |                | the specified time (using ACE_Reactor)
00045  * |                |
00046  * |0,0  | yes      | poll; try, if EWOULDBLOCK,
00047  * |                | then return immediately
00048  * |                | (using ACE_Reactor)
00049  * |                |
00050  * |NULL | no       | block forever (don't use ACE_Reactor)
00051  * |                |
00052  * |time | no       | do a blocking transaction
00053  * |                | for the specified time
00054  * |                | (don't use ACE_Reactor)
00055  * |                |
00056  * |0,0  | no       | poll; but do not initiate a
00057  * |                | nonblocking transaction
00058  * |                | (don't use ACE_Reactor)
00059  * </CODE>
00060  */
00061 class ACE_Export ACE_Synch_Options
00062 {
00063 public:
00064   /// Options flags for controlling synchronization.
00065   /**
00066    * Note that these flags can be bit-wise "or'd" together if both
00067    * options are desired.
00068    */
00069   enum
00070   {
00071     /// Use the Reactor.
00072     USE_REACTOR = 01,
00073     /// Interprete the Time_Value.
00074     USE_TIMEOUT = 02
00075   };
00076 
00077   // = Initialization methods.
00078   /// Initialize the Synch_Options based on parameters.
00079   ACE_Synch_Options (u_long options = 0,
00080                      const ACE_Time_Value &timeout = ACE_Time_Value::zero,
00081                      const void *arg = 0);
00082 
00083   /// Default dtor.
00084   ~ACE_Synch_Options (void);
00085 
00086   /// Initialize the Synch_Options based on parameters.
00087   void set (u_long options = 0,
00088             const ACE_Time_Value &timeout = ACE_Time_Value::zero,
00089             const void *arg = 0);
00090 
00091   /// Get method for determining which options are enabled.
00092   int operator[] (u_long option) const;
00093 
00094   /// Set method for enabling certain options.
00095   void operator= (u_long option);
00096 
00097   /// Returns the "magic cookie" argument.
00098   const void *arg (void) const;
00099 
00100   /// Set the "magic cookie" argument.
00101   void arg (const void *);
00102 
00103   /// Returns a reference to the <Time_Value>.  This value only makes
00104   /// sense if (*this)[USE_TIMEOUT] is true.
00105   const ACE_Time_Value &timeout (void) const;
00106 
00107   /// Set the <Time_Value>.
00108   void timeout (const ACE_Time_Value &tv);
00109 
00110   /**
00111    * Returns the address of the timeout <Time_Value> if
00112    * (*this)[USE_TIMEOUT] is true, else 0.  This should be used with
00113    * care, e.g., the timeout pointer should not be stored in a manner
00114    * that will lead to dangling pointers...
00115    */
00116   const ACE_Time_Value *time_value (void) const;
00117 
00118   // = Static data members (singletons)
00119 
00120   /// This is the default setting for options, which will block
00121   /// synchronously.
00122   static ACE_Synch_Options defaults;
00123 
00124   /// This is the default synchronous setting.
00125   static ACE_Synch_Options synch;
00126 
00127   /// This is the default asynchronous setting.
00128   static ACE_Synch_Options asynch;
00129 
00130   /// Dump the state of an object.
00131   void dump (void) const;
00132 
00133   /// Declare the dynamic allocation hooks.
00134   ACE_ALLOC_HOOK_DECLARE;
00135 
00136 private:
00137   /// Keeps track of the enabled options.
00138   u_long options_;
00139 
00140   /// Amount of time to wait for timeouts.
00141   ACE_Time_Value timeout_;
00142 
00143   /**
00144    * "Magic cookie" always passed in as an argument to the ACE_Reactor's
00145    * <schedule_timer> method.  Used to communicate values for
00146    * asynchronous programming.
00147    */
00148   const void *arg_;
00149 };
00150 
00151 #if defined (__ACE_INLINE__)
00152 #include "ace/Synch_Options.i"
00153 #endif /* __ACE_INLINE__ */
00154 
00155 #include "ace/post.h"
00156 
00157 #endif /* ACE_SYNCH_OPTIONS_H */

Generated on Mon Jun 16 11:21:40 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002