blob: a899db89c3f84356f242a4d50bbd697a79f866fb (
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
|
// -*- C++ -*-
// $Id$
#include "orbsvcs/LoadBalancing/Round_Robin_Strategy.h"
ACE_RCSID(orbsvcs, Round_Robin_Strategy, "$Id$")
Round_Robin_Strategy::Round_Robin_Strategy (void)
: proxies_ (),
next_replica_ (this->proxies_.end ())
{
// Nothing else
}
Round_Robin_Strategy::~Round_Robin_Strategy (void)
{
ReplicaProxySetIterator begin = this->proxies_.begin ();
ReplicaProxySetIterator end = this->proxies_.end ();
for (ReplicaProxySetIterator i = begin;
i != end;
++i)
{
// Decrease reference count on each proxy servant in the set.
(*i)->_remove_ref ();
}
}
CORBA::Object_ptr
Round_Robin_Strategy::replica (CORBA::Environment &ACE_TRY_ENV)
{
if (this->proxies_.is_empty ())
{
// @@ What do we do if the set is empty?
ACE_THROW_RETURN (CORBA::INTERNAL (),
CORBA::Object::_nil ());
}
// If we're at the end of the Replica set, then rewind to the
// beginning of the set.
if (this->next_replica_ == this->proxies_.end ())
this->next_replica_ == this->proxies_.begin ();
ReplicaProxy_Impl * proxy_servant = *(this->next_replica_);
// Advance to the next Replica in the set in preparation for the
// next call to this method.
this->next_replica_++;
return proxy_servant->_this (ACE_TRY_ENV);
}
int
Round_Robin_Strategy::insert (ReplicaProxy_Impl *proxy)
{
return this->proxies_.insert (proxy)
}
int
Round_Robin_Strategy::remove (ReplicaProxy_Impl *proxy)
{
return this->proxies_.remove (proxy);
}
|