blob: b6c5474b37f3022debb85661613e9340a5e13189 (
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
96
97
98
99
100
101
102
103
104
105
106
107
|
#include "tao/ObjectKey_Table.h"
#include "tao/ORB_Core.h"
#include "tao/Refcounted_ObjectKey.h"
#if !defined (__ACE_INLINE__)
# include "tao/ObjectKey_Table.inl"
#endif /* ! __ACE_INLINE__ */
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
bool
TAO::Less_Than_ObjectKey::operator () (const TAO::ObjectKey &lhs,
const TAO::ObjectKey &rhs) const
{
const CORBA::ULong rlen = rhs.length ();
const CORBA::ULong llen = lhs.length ();
if (llen < rlen)
{
return 1;
}
else if (llen > rlen)
{
return 0;
}
const CORBA::Octet * rhs_buff = rhs.get_buffer ();
const CORBA::Octet * lhs_buff = lhs.get_buffer ();
const bool result = (ACE_OS::memcmp (lhs_buff, rhs_buff, rlen) < 0);
return result;
}
/********************************************************/
TAO::ObjectKey_Table::ObjectKey_Table ()
: table_ ()
{
}
TAO::ObjectKey_Table::~ObjectKey_Table ()
{
this->table_.close ();
}
int
TAO::ObjectKey_Table::destroy ()
{
if (this->table_.current_size ())
{
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
ace_mon,
this->lock_,
0);
TABLE::ITERATOR end_iter = this->table_.end ();
TABLE::ITERATOR start;
while ((start = this->table_.begin ()) != end_iter)
{
TABLE::ENTRY &ent = (*start);
ent.item ()->decr_refcount ();
this->table_.unbind (&ent);
}
}
return 0;
}
int
TAO::ObjectKey_Table::bind_i (const TAO::ObjectKey &key,
TAO::Refcounted_ObjectKey *&key_new)
{
ACE_NEW_RETURN (key_new,
TAO::Refcounted_ObjectKey (key),
-1);
int const retval = this->table_.bind (key, key_new);
if (retval != -1)
{
key_new->incr_refcount ();
}
else
{
key_new->decr_refcount ();
}
return retval;
}
int
TAO::ObjectKey_Table::unbind_i (TAO::Refcounted_ObjectKey *&key_new)
{
TAO::Refcounted_ObjectKey *tmp = nullptr;
if (this->table_.unbind (key_new->object_key (), tmp) != -1)
{
// @@ Cant do much if the unbind fails.
// Remove our refcount on the ObjectKey
(void) tmp->decr_refcount ();
}
return 0;
}
TAO_END_VERSIONED_NAMESPACE_DECL
|