#include <Synch_Options.h>
Collaboration diagram for ACE_Synch_Options:
Public Types | |
USE_REACTOR = 01 | |
Use the Reactor. | |
USE_TIMEOUT = 02 | |
Use the supplied timeout value. | |
enum | { USE_REACTOR = 01, USE_TIMEOUT = 02 } |
Options flags for controlling synchronization. More... | |
Public Member Functions | |
ACE_Synch_Options (unsigned long options=0, const ACE_Time_Value &timeout=ACE_Time_Value::zero, const void *arg=0) | |
void | set (unsigned long options=0, const ACE_Time_Value &timeout=ACE_Time_Value::zero, const void *arg=0) |
bool | operator[] (unsigned long option) const |
Returns true if the specified option(s) are enabled, false otherwise. | |
void | operator= (unsigned long option) |
Adds the specified option(s) to the object; does not replace them. | |
const void * | arg (void) const |
Returns the "magic cookie" argument. | |
void | arg (const void *) |
Set the "magic cookie" argument. | |
const ACE_Time_Value & | timeout (void) const |
void | timeout (const ACE_Time_Value &tv) |
const ACE_Time_Value * | time_value (void) const |
void | dump (void) const |
Dump the state of an object. | |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. | |
Static Public Attributes | |
static ACE_Synch_Options | defaults |
static ACE_Synch_Options | synch |
This is the default synchronous setting. | |
static ACE_Synch_Options | asynch |
This is the default asynchronous setting. | |
Private Attributes | |
unsigned long | options_ |
Keeps track of the enabled options. | |
ACE_Time_Value | timeout_ |
Amount of time to wait for timeouts. | |
const void * | arg_ |
The supported set of options is depicted in the following table. The Reactor column indicates whether or not the USE_REACTOR option is supplied. The Timeout column specifies the period of time specified by the object; Unused implies that USE_TIMEOUT is not included in the options and the default timeout value, ACE_Time_Value::zero, is specified, either explicitly or by default.
Reactor | Timeout | Behavior |
yes | Unused | Infinite timeout (using Reactor); this is the default. |
yes | time | Try asynch transaction for the specified time (using Reactor) |
yes | 0,0 | Poll; try, if EWOULDBLOCK, return immediately (using Reactor) |
no | Unused | Block until completion (don't use Reactor) |
no | time | Wait up to specified amount of time for completion (don't use Reactor) |
no | 0,0 | Poll and return immediately |
Definition at line 56 of file Synch_Options.h.
anonymous enum |
Options flags for controlling synchronization.
Note that these flags can be bit-wise "or'd" together if both options are desired.
Definition at line 64 of file Synch_Options.h.
00065 { 00066 /// Use the Reactor. 00067 USE_REACTOR = 01, 00068 /// Use the supplied timeout value. 00069 USE_TIMEOUT = 02 00070 };
ACE_Synch_Options::ACE_Synch_Options | ( | unsigned long | options = 0 , |
|
const ACE_Time_Value & | timeout = ACE_Time_Value::zero , |
|||
const void * | arg = 0 | |||
) |
Initialize the object to default values unless specified otherwise.
options | Specifies the options to use; default is neither option (no reactor, no timeout). | |
timeout | Specifies the period of time to use for the operation's timeout. The default is ACE_Time_Value::zero, noted as 0,0 in the behavior options table. If a non-zero timeout is specified, the USE_TIMEOUT option is added to options. To use a zero timeout, USE_TIMEOUT must be explicitly specified in options. | |
arg | A completion tag that can be passed through the options; the class using ACE_Synch_Options can access this. ACE_Synch_Options makes no use of it internally. |
Definition at line 34 of file Synch_Options.cpp.
References set(), and timeout().
00037 { 00038 // ACE_TRACE ("ACE_Synch_Options::ACE_Synch_Options"); 00039 this->set (options, timeout, arg); 00040 }
void ACE_Synch_Options::arg | ( | const void * | ) |
const void * ACE_Synch_Options::arg | ( | void | ) | const |
Returns the "magic cookie" argument.
Definition at line 97 of file Synch_Options.cpp.
References ACE_TRACE, and arg_.
Referenced by ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::nonblocking_connect(), and ACE_Oneshot_Acceptor< SVC_HANDLER, >::register_handler().
ACE_BEGIN_VERSIONED_NAMESPACE_DECL void ACE_Synch_Options::dump | ( | void | ) | const |
Dump the state of an object.
Definition at line 15 of file Synch_Options.cpp.
References ACE_TRACE.
00016 { 00017 #if defined (ACE_HAS_DUMP) 00018 ACE_TRACE ("ACE_Synch_Options::dump"); 00019 #endif /* ACE_HAS_DUMP */ 00020 }
void ACE_Synch_Options::operator= | ( | unsigned long | option | ) |
bool ACE_Synch_Options::operator[] | ( | unsigned long | option | ) | const |
Returns true if the specified option(s) are enabled, false otherwise.
Definition at line 62 of file Synch_Options.cpp.
References ACE_TRACE.
00063 { 00064 ACE_TRACE ("ACE_Synch_Options::operator[]"); 00065 return (this->options_ & option) != 0; 00066 }
void ACE_Synch_Options::set | ( | unsigned long | options = 0 , |
|
const ACE_Time_Value & | timeout = ACE_Time_Value::zero , |
|||
const void * | arg = 0 | |||
) |
Initialize the object; arguments are the same as for the constructor.
Definition at line 43 of file Synch_Options.cpp.
References ACE_SET_BITS, arg_, options_, timeout(), timeout_, USE_TIMEOUT, and ACE_Time_Value::zero.
Referenced by ACE_Synch_Options().
00046 { 00047 // ACE_TRACE ("ACE_Synch_Options::set"); 00048 this->options_ = options; 00049 this->timeout_ = timeout; 00050 00051 // Whoa, possible dependence on static initialization here. This 00052 // function is called during initialization of the statics above. 00053 // But, ACE_Time_Value::zero is a static object. Very fortunately, 00054 // its bits have a value of 0. 00055 if (this->timeout_ != ACE_Time_Value::zero) 00056 ACE_SET_BITS (this->options_, ACE_Synch_Options::USE_TIMEOUT); 00057 00058 this->arg_ = arg; 00059 }
const ACE_Time_Value * ACE_Synch_Options::time_value | ( | void | ) | const |
Returns a timeout pointer if (*this)[USE_TIMEOUT] is true, else 0. This should be used with care, e.g., the timeout pointer should not be stored in a manner that will lead to dangling pointers.
Definition at line 90 of file Synch_Options.cpp.
References ACE_TRACE, timeout_, and USE_TIMEOUT.
Referenced by ACE_Oneshot_Acceptor< SVC_HANDLER, >::accept(), ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::connect_i(), ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::nonblocking_connect(), ACE_Name_Proxy::open(), and ACE_Oneshot_Acceptor< SVC_HANDLER, >::register_handler().
00091 { 00092 ACE_TRACE ("ACE_Synch_Options::time_value"); 00093 return (*this)[USE_TIMEOUT] ? &this->timeout_ : 0; 00094 }
void ACE_Synch_Options::timeout | ( | const ACE_Time_Value & | tv | ) |
Set the timeout value. This method does not alter the options; in particular, it doesn't add USE_TIMEOUT to the options when a non-zero timeout is specified as the constructor and set() do.
Definition at line 83 of file Synch_Options.cpp.
References ACE_TRACE, and timeout_.
const ACE_Time_Value & ACE_Synch_Options::timeout | ( | void | ) | const |
Returns a reference to the ACE_Time_Value. This value only makes sense if (*this)[USE_TIMEOUT] is true.
Definition at line 76 of file Synch_Options.cpp.
References ACE_TRACE, and timeout_.
Referenced by ACE_Synch_Options(), and set().
const void* ACE_Synch_Options::arg_ [private] |
"Magic cookie" always passed in as an argument to the ACE_Reactor's schedule_timer() method. Used to communicate values for asynchronous programming.
Definition at line 156 of file Synch_Options.h.
This is the default setting for options, which will block synchronously.
Definition at line 130 of file Synch_Options.h.
unsigned long ACE_Synch_Options::options_ [private] |
Keeps track of the enabled options.
Definition at line 146 of file Synch_Options.h.
Referenced by operator=(), and set().
ACE_Time_Value ACE_Synch_Options::timeout_ [private] |
Amount of time to wait for timeouts.
Definition at line 149 of file Synch_Options.h.
Referenced by set(), time_value(), and timeout().