00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Connect_Strategy.h 00006 * 00007 * $Id: Connect_Strategy.h 74014 2006-08-14 13:52:22Z johnnyw $ 00008 * 00009 * @author Balachandran Natarajan <bala@cs.wustl.edu> 00010 */ 00011 //============================================================================= 00012 00013 #ifndef TAO_CONNECT_STRATEGY_H 00014 #define TAO_CONNECT_STRATEGY_H 00015 00016 #include /**/ "ace/pre.h" 00017 00018 #include /**/ "tao/TAO_Export.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 # pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 #include /**/ "tao/Versioned_Namespace.h" 00025 00026 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00027 class ACE_Synch_Options; 00028 class ACE_Time_Value; 00029 ACE_END_VERSIONED_NAMESPACE_DECL 00030 00031 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00032 00033 class TAO_ORB_Core; 00034 class TAO_Connector; 00035 class TAO_Connection_Handler; 00036 class TAO_Transport; 00037 class TAO_LF_Multi_Event; 00038 class TAO_LF_Event; 00039 00040 /** 00041 * @class TAO_Connect_Strategy 00042 * 00043 * @brief Define the interface for the connect strategy, i.e. the 00044 * algorithm that controls how does the ORB establishes remote 00045 * connections. 00046 * 00047 * The thread that establishes remote connections can either make a 00048 * blocking or a non-blocking connect. The strategy to wait for the 00049 * connection completion can also be different. 00050 * 00051 * This strategy controls how does the ORB schedules and waits for 00052 * connection completion. 00053 */ 00054 00055 class TAO_Export TAO_Connect_Strategy 00056 { 00057 public: 00058 00059 /// Constructor 00060 TAO_Connect_Strategy (TAO_ORB_Core *orb); 00061 00062 /// Destructor 00063 virtual ~TAO_Connect_Strategy (void); 00064 00065 /// Obtain the synch options that can be passed to ACE_Connector 00066 /* Return the synch option for the connector, based on the timeout 00067 * and the strategy in place. ACE_Connectors behavior can be altered 00068 * by passing the right ACE_Synch_Options to the connect () call. 00069 */ 00070 virtual void synch_options (ACE_Time_Value *val, 00071 ACE_Synch_Options &opt) = 0; 00072 00073 /// Wait for the connection to be completed till a timeout occurs. 00074 /* If the connection establishment fails the state within the 00075 * connection handler is set appropriately. 00076 */ 00077 int wait (TAO_Connection_Handler *ch, ACE_Time_Value *val); 00078 00079 int wait (TAO_Transport *t, ACE_Time_Value *val); 00080 00081 /// Wait for one of many connections to complete. Returns when one 00082 /// succeeds or all fail. 00083 int wait (TAO_LF_Multi_Event *ev, ACE_Time_Value *val); 00084 00085 /// Do a quick check to see if any connections are complete. This 00086 /// does the same as the wait with an explicit time value of 0. 00087 int poll (TAO_LF_Multi_Event *ev); 00088 00089 protected: 00090 /// This is the method that does all the real interesting stuff. 00091 virtual int wait_i (TAO_LF_Event *ev, 00092 TAO_Transport *t, 00093 ACE_Time_Value *val) = 0; 00094 00095 /// Cached copy of the ORB core pointer 00096 TAO_ORB_Core * const orb_core_; 00097 00098 }; 00099 00100 TAO_END_VERSIONED_NAMESPACE_DECL 00101 00102 #include /**/ "ace/post.h" 00103 #endif /*TAO_CONNECT_STRATEGY_H*/