3
//==========================================================================
5
* @file Synch_Options.h
7
* Synch_Options.h,v 4.19 2003/07/19 19:04:13 dhinton Exp
9
* @author Douglas C. Schmidt <schmidt@uci.edu>
11
//==========================================================================
13
#ifndef ACE_SYNCH_OPTIONS_H
14
#define ACE_SYNCH_OPTIONS_H
16
#include /**/ "ace/pre.h"
18
#include "ace/ACE_export.h"
20
#if !defined (ACE_LACKS_PRAGMA_ONCE)
22
#endif /* ACE_LACKS_PRAGMA_ONCE */
24
#include "ace/Time_Value.h"
28
* @class ACE_Synch_Options
30
* @brief Contains the values of options used to determine the
31
* synchronous and asynchronous behavior.
33
* Values support the following behavior (TV == "timeout"
34
* and UR == "use ACE_Reactor"):
37
* | Parameters | Description
40
* |-----|----------|-------------------------------
42
* |NULL | yes | infinite timeout (using ACE_Reactor)
44
* |time | yes | try asynch transaction for
45
* | | the specified time (using ACE_Reactor)
47
* |0,0 | yes | poll; try, if EWOULDBLOCK,
48
* | | then return immediately
49
* | | (using ACE_Reactor)
51
* |NULL | no | block forever (don't use ACE_Reactor)
53
* |time | no | do a blocking transaction
54
* | | for the specified time
55
* | | (don't use ACE_Reactor)
57
* |0,0 | no | poll; but do not initiate a
58
* | | nonblocking transaction
59
* | | (don't use ACE_Reactor)
62
class ACE_Export ACE_Synch_Options
65
/// Options flags for controlling synchronization.
67
* Note that these flags can be bit-wise "or'd" together if both
68
* options are desired.
74
/// Interprete the Time_Value.
78
// = Initialization methods.
79
/// Initialize the Synch_Options based on parameters.
80
ACE_Synch_Options (unsigned long options = 0,
81
const ACE_Time_Value &timeout = ACE_Time_Value::zero,
85
~ACE_Synch_Options (void);
87
/// Initialize the Synch_Options based on parameters.
88
void set (unsigned long options = 0,
89
const ACE_Time_Value &timeout = ACE_Time_Value::zero,
92
/// Get method for determining which options are enabled.
93
int operator[] (unsigned long option) const;
95
/// Set method for enabling certain options.
96
void operator= (unsigned long option);
98
/// Returns the "magic cookie" argument.
99
const void *arg (void) const;
101
/// Set the "magic cookie" argument.
102
void arg (const void *);
104
/// Returns a reference to the <Time_Value>. This value only makes
105
/// sense if (*this)[USE_TIMEOUT] is true.
106
const ACE_Time_Value &timeout (void) const;
108
/// Set the <Time_Value>.
109
void timeout (const ACE_Time_Value &tv);
112
* Returns the address of the timeout <Time_Value> if
113
* (*this)[USE_TIMEOUT] is true, else 0. This should be used with
114
* care, e.g., the timeout pointer should not be stored in a manner
115
* that will lead to dangling pointers...
117
const ACE_Time_Value *time_value (void) const;
119
// = Static data members (singletons)
121
/// This is the default setting for options, which will block
123
static ACE_Synch_Options defaults;
125
/// This is the default synchronous setting.
126
static ACE_Synch_Options synch;
128
/// This is the default asynchronous setting.
129
static ACE_Synch_Options asynch;
131
/// Dump the state of an object.
132
void dump (void) const;
134
/// Declare the dynamic allocation hooks.
135
ACE_ALLOC_HOOK_DECLARE;
138
/// Keeps track of the enabled options.
139
unsigned long options_;
141
/// Amount of time to wait for timeouts.
142
ACE_Time_Value timeout_;
145
* "Magic cookie" always passed in as an argument to the ACE_Reactor's
146
* <schedule_timer> method. Used to communicate values for
147
* asynchronous programming.
152
#if defined (__ACE_INLINE__)
153
#include "ace/Synch_Options.i"
154
#endif /* __ACE_INLINE__ */
156
#include /**/ "ace/post.h"
158
#endif /* ACE_SYNCH_OPTIONS_H */