summaryrefslogtreecommitdiff
path: root/TAO/tao/CSD_ThreadPool/CSD_TP_Servant_State_Map.h
blob: ccbec859ea4ea0e3d136d9268bb55ad44b30a470 (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
93
94
95
// -*- C++ -*-

//=============================================================================
/**
 *  @file    CSD_TP_Servant_State_Map.h
 *
 *  $Id$
 *
 *  @author  Tim Bradley <bradley_t@ociweb.com>
 */
//=============================================================================

#ifndef TAO_CSD_TP_SERVANT_STATE_MAP_H
#define TAO_CSD_TP_SERVANT_STATE_MAP_H

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

#include "tao/CSD_ThreadPool/CSD_TP_Export.h"

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

#include "tao/CSD_ThreadPool/CSD_TP_Servant_State.h"
#include "tao/PortableServer/PortableServer.h"
#include "ace/Hash_Map_Manager.h"
#include "ace/Synch.h"

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

namespace TAO
{
  namespace CSD
  {

    /**
     * @class TP_Servant_State_Map
     *
     * @brief Map of Servant_State objects - one per servant.
     *
     * A TP_Stategy object holds an instance of a TP_Servant_State_Map object
     * as a (held-by-value) data member.  The strategy uses this map to
     * find or create the TP_Servant_State object for a particular servant
     * object.
     *
     */
    class TAO_CSD_TP_Export TP_Servant_State_Map
    {
    public:

      /// Default Constructor.
      TP_Servant_State_Map();

      /// Destructor.
      ~TP_Servant_State_Map();

      /// Accessor for the servant busy flag.
      TP_Servant_State* find(PortableServer::Servant servant
                            );

      /// Insert the servant to map.
      void insert(PortableServer::Servant servant
                 );

      /// Remove the servant from map.
      void remove(PortableServer::Servant servant
                 );


    private:

      /// Underlying Map Type - Hash-Based -
      /// Key Type: void*, Value Type: TP_Servant_State::HandleType
      typedef ACE_Hash_Map_Manager_Ex<void*,
                                      TP_Servant_State::HandleType,
                                      ACE_Hash<void*>,
                                      ACE_Equal_To<void*>,
                                      ACE_SYNCH_MUTEX>            MapType;

      /// The underlying map of servant state objects.
      MapType map_;
    };

  }
}

TAO_END_VERSIONED_NAMESPACE_DECL

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

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

#endif /* TAO_CSD_TP_SERVANT_STATE_MAP_H */