Synch_Options.h

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

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