summaryrefslogtreecommitdiff
path: root/TAO/tao/Cleanup_Func_Registry.h
blob: cc2c6162c9784b2abdc74c135ad8a38265ff37c2 (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
92
// -*- C++ -*-

// ===================================================================
/**
 *  @file   Cleanup_Func_Registry.h
 *
 *  $Id$
 *
 *  @author Ossama Othman <ossama@dre.vanderbilt.edu>
 */
// ===================================================================

#ifndef TAO_CLEANUP_FUNC_REGISTRY_H
#define TAO_CLEANUP_FUNC_REGISTRY_H

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

#include "tao/TAO_Export.h"

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

#include "tao/Versioned_Namespace.h"

#include "ace/Array_Base.h"


TAO_BEGIN_VERSIONED_NAMESPACE_DECL

/**
 * @class TAO_Cleanup_Func_Registry
 *
 * @brief
 * This is a helper class that is designed to perform cleanup on
 * thread-specific objects registered in the ORB Core TSS resources by
 * invoking the corresponding cleanup function on each object.  Hence,
 * there is a tight coupling between this class and the TAO ORB Core.
 */
class TAO_Cleanup_Func_Registry
{
  friend class TAO_ORB_Core;

public:

  /// Constructor.
  TAO_Cleanup_Func_Registry (void);

  /// Return the number of registered cleanup functions.
  size_t size (void) const;

protected:

  /// Register a cleanup function.  The number of slot the cleanup
  /// function is placed is in will match the one reserved for the
  /// corresponding thread specific object in the ORB Core TSS
  /// resources.  The slot_id is returned via the second reference
  /// argument.  This method returns 0 on failure, and -1 on failure.
  int register_cleanup_function (ACE_CLEANUP_FUNC func,
                                 size_t &slot_id);

  /// Invoke the corresponding cleanup function on each
  /// thread-specific object.
  void cleanup (ACE_Array_Base<void *> &ts_objects);

private:

  /// Prevent copying through the copy constructor and the assignment
  /// operator.
  TAO_Cleanup_Func_Registry (const TAO_Cleanup_Func_Registry &);
  void operator= (const TAO_Cleanup_Func_Registry &);

private:

  /// Array of registered cleanup functions.  The number of
  /// registered cleanup functions should be the same as the number
  /// of registered thread-specific objects in the ORB Core TSS
  /// resources.
  ACE_Array_Base<ACE_CLEANUP_FUNC> cleanup_funcs_;

};

TAO_END_VERSIONED_NAMESPACE_DECL

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


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

#endif  /* TAO_CLEANUP_FUNC_REGISTRY_H */