summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/AdapterCache.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2006-03-29 08:42:35 +0000
committerBenoit Foucher <benoit@zeroc.com>2006-03-29 08:42:35 +0000
commitf2b162b67c2382a2da555e7a960beaa3ab6b3997 (patch)
tree5ba1d3a23c1f6ea4e1792f77b762d2fb17bb7bde /cpp/src/IceGrid/AdapterCache.cpp
parentFixed invalid implicit conversion (diff)
downloadice-f2b162b67c2382a2da555e7a960beaa3ab6b3997.tar.bz2
ice-f2b162b67c2382a2da555e7a960beaa3ab6b3997.tar.xz
ice-f2b162b67c2382a2da555e7a960beaa3ab6b3997.zip
Random fixes.
Diffstat (limited to 'cpp/src/IceGrid/AdapterCache.cpp')
-rw-r--r--cpp/src/IceGrid/AdapterCache.cpp20
1 files changed, 5 insertions, 15 deletions
diff --git a/cpp/src/IceGrid/AdapterCache.cpp b/cpp/src/IceGrid/AdapterCache.cpp
index d7f263a349e..00bef5b40a7 100644
--- a/cpp/src/IceGrid/AdapterCache.cpp
+++ b/cpp/src/IceGrid/AdapterCache.cpp
@@ -18,6 +18,8 @@
using namespace std;
using namespace IceGrid;
+pointer_to_unary_function<int, int> ReplicaGroupEntry::_rand(IceUtil::random);
+
namespace IceGrid
{
@@ -332,17 +334,14 @@ ReplicaGroupEntry::getProxies(bool allRegistered, int& nReplicas)
else if(AdaptiveLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
{
replicas = _replicas;
+ random_shuffle(replicas.begin(), replicas.end(), _rand);
adaptive = true;
loadSample = _loadSample;
}
else// if(RandomLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
{
replicas = _replicas;
-#ifdef _MSC_VER
- random_shuffle(replicas.begin(), replicas.end(), ptr_fun(IceUtil::random));
-#else
- random_shuffle(replicas.begin(), replicas.end(), IceUtil::random);
-#endif
+ random_shuffle(replicas.begin(), replicas.end(), _rand);
}
}
@@ -352,11 +351,6 @@ ReplicaGroupEntry::getProxies(bool allRegistered, int& nReplicas)
// This must be done outside the synchronization block since
// the sort() will call and lock each server entry.
//
-#ifdef _MSC_VER
- random_shuffle(replicas.begin(), replicas.end(), ptr_fun(IceUtil::random));
-#else
- random_shuffle(replicas.begin(), replicas.end(), IceUtil::random);
-#endif
sort(replicas.begin(), replicas.end(), ServerLoadCI(loadSample));
}
@@ -399,11 +393,7 @@ ReplicaGroupEntry::getLeastLoadedNodeLoad(LoadSample loadSample) const
// This must be done outside the synchronization block since
// min_element() will call and lock each server entry.
//
-#ifdef _MSC_VER
- random_shuffle(replicas.begin(), replicas.end(), ptr_fun(IceUtil::random));
-#else
- random_shuffle(replicas.begin(), replicas.end(), IceUtil::random);
-#endif
+ random_shuffle(replicas.begin(), replicas.end(), _rand);
AdapterEntryPtr adpt = min_element(replicas.begin(), replicas.end(), ServerLoadCI(loadSample))->second;
return adpt->getLeastLoadedNodeLoad(loadSample);
}