00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Resume_Handle.h 00006 * 00007 * $Id: Resume_Handle.h 82447 2008-07-28 14:21:47Z johnnyw $ 00008 * 00009 * @author Balachandran Natarajan <bala@cs.wustl.edu> 00010 */ 00011 //============================================================================= 00012 00013 #ifndef TAO_RESUME_HANDLE_H 00014 #define TAO_RESUME_HANDLE_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 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00027 00028 class TAO_ORB_Core; 00029 00030 /** 00031 * @class TAO_Resume_Handle 00032 * 00033 * @brief A utility class that helps in resuming handlers if TAO uses 00034 * a TP Reactor from ACE. 00035 * 00036 * Please read the documentation in the bugzilla #575 in the bugzilla 00037 * database what we mean by handler resumption. 00038 * 00039 * When TAO uses a TP reactor, it takes care of resuming the handler 00040 * once it makes sure that it has read the whole message out of the 00041 * socket. During the process of reading the transport object would 00042 * have to deal with errors in 'read' from the socket, or errors in 00043 * the messages that has been received. Instead of calling 00044 * resume_handler () on the reactor at every point in the code, we 00045 * use this utility class to take care of the resumption. 00046 */ 00047 class TAO_Export TAO_Resume_Handle 00048 { 00049 00050 public: 00051 00052 /// Constructor. 00053 TAO_Resume_Handle (TAO_ORB_Core *orb_core = 0, 00054 ACE_HANDLE h = ACE_INVALID_HANDLE); 00055 /// Destructor 00056 ~TAO_Resume_Handle (void); 00057 00058 enum TAO_Handle_Resume_Flag 00059 { 00060 TAO_HANDLE_RESUMABLE = 0, 00061 TAO_HANDLE_ALREADY_RESUMED, 00062 TAO_HANDLE_LEAVE_SUSPENDED 00063 }; 00064 00065 /// Allow the users of this class to change the underlying flag. 00066 void set_flag (TAO_Handle_Resume_Flag fl); 00067 00068 /// Assignment operator 00069 TAO_Resume_Handle &operator= (const TAO_Resume_Handle &rhs); 00070 00071 /// Resume the handle in the reactor only if the ORB uses a TP 00072 /// reactor. Else we don't resume the handle. 00073 void resume_handle (void); 00074 00075 /// Hook method called at the end of a connection handler's 00076 /// handle_input function. Might override the handle_input 00077 /// return value or change the resume_handler's flag_ value. 00078 void handle_input_return_value_hook (int& return_value); 00079 00080 private: 00081 00082 /// Our ORB Core. 00083 TAO_ORB_Core *orb_core_; 00084 00085 /// The actual handle that needs resumption.. 00086 ACE_HANDLE handle_; 00087 00088 /// The flag for indicating whether the handle has been resumed or 00089 /// not. A value of '0' indicates that the handle needs resumption. 00090 TAO_Handle_Resume_Flag flag_; 00091 }; 00092 00093 TAO_END_VERSIONED_NAMESPACE_DECL 00094 00095 #if defined (__ACE_INLINE__) 00096 # include "tao/Resume_Handle.inl" 00097 #endif /* __ACE_INLINE__ */ 00098 00099 #include /**/ "ace/post.h" 00100 00101 #endif /*TAO_RESUME_HANDLE*/