summaryrefslogtreecommitdiff
path: root/TAO/tao/Resume_Handle.h
blob: 44aed27e2661b9e9ba42485dcfc4e8ed5a786cfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// -*- C++ -*-

//=============================================================================
/**
 *  @file Resume_Handle.h
 *
 *  $Id$
 *
 *  @author Balachandran Natarajan <bala@cs.wustl.edu>
 */
//=============================================================================

#ifndef TAO_RESUME_HANDLE_H
#define TAO_RESUME_HANDLE_H

#include /**/ "ace/pre.h"

#include "TAO_Export.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

class TAO_ORB_Core;

/**
 * @class TAO_Resume_Handle
 *
 * @brief A utility class that helps in resuming handlers if TAO uses
 *  a TP Reactor from ACE.
 *
 * Please read the documentation in the bugzilla #575 in the bugzilla
 * database what we mean by handler resumption.
 *
 * When TAO uses a TP reactor, it takes care of resuming the handler
 * once it makes sure that it has read the whole message out of the
 * socket. During the process of reading the transport object would
 * have to deal with errors in 'read' from the socket, or errors in
 * the messages that has been received. Instead of calling
 * resume_handler () on the reactor at every point in the code, we
 * use this utility class to take care of the resumption.
 */

class TAO_Export TAO_Resume_Handle
{

public:

  /// Ctor.
  TAO_Resume_Handle (TAO_ORB_Core *orb_core = 0,
                     ACE_HANDLE h = ACE_INVALID_HANDLE);
  /// Dtor
  ~TAO_Resume_Handle (void);

  enum TAO_Handle_Resume_Flag
  {
    TAO_HANDLE_RESUMABLE = 0,
    TAO_HANDLE_ALREADY_RESUMED,
    TAO_HANDLE_LEAVE_SUSPENDED
  };

  /// Allow the users of this class to change the underlying flag.
  void set_flag (TAO_Handle_Resume_Flag fl);

  /// Equal to operator..
  TAO_Resume_Handle &operator= (const TAO_Resume_Handle &rhs);

  /// Resume the handle in the reactor only if the ORB uses a TP
  /// reactor. Else we dont resume the handle.
  void resume_handle (void);

private:

  /// Our ORB Core.
  TAO_ORB_Core *orb_core_;

  /// The actual handle that needs resumption..
  ACE_HANDLE handle_;

  /// The flag for indicating whether the handle has been resumed or
  /// not. A value of '0' indicates that the handle needs resumption.
  TAO_Handle_Resume_Flag flag_;
};

#if defined (__ACE_INLINE__)
# include "Resume_Handle.inl"
#endif /* __ACE_INLINE__ */

#include /**/ "ace/post.h"

#endif /*TAO_RESUME_HANDLE*/