diff options
author | Marc Laukien <marc@zeroc.com> | 2002-01-14 18:43:01 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2002-01-14 18:43:01 +0000 |
commit | f453785066eff4e8d9f5c7fd63bd01b4260020ed (patch) | |
tree | 1410e9fc19a52042879f9f06fe9e6c1ecb443e2a /cpp/src/Ice/RoutingTable.cpp | |
parent | file ServerBlobject.cpp was initially added on branch glacier. (diff) | |
download | ice-f453785066eff4e8d9f5c7fd63bd01b4260020ed.tar.bz2 ice-f453785066eff4e8d9f5c7fd63bd01b4260020ed.tar.xz ice-f453785066eff4e8d9f5c7fd63bd01b4260020ed.zip |
glacier intergration
Diffstat (limited to 'cpp/src/Ice/RoutingTable.cpp')
-rw-r--r-- | cpp/src/Ice/RoutingTable.cpp | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/cpp/src/Ice/RoutingTable.cpp b/cpp/src/Ice/RoutingTable.cpp new file mode 100644 index 00000000000..e1e88f5804c --- /dev/null +++ b/cpp/src/Ice/RoutingTable.cpp @@ -0,0 +1,98 @@ +// ********************************************************************** +// +// Copyright (c) 2001 +// MutableRealms, Inc. +// Huntsville, AL, USA +// +// All Rights Reserved +// +// ********************************************************************** + +#include <Ice/RoutingTable.h> +#include <Ice/Proxy.h> + +using namespace std; +using namespace Ice; +using namespace IceInternal; + +void IceInternal::incRef(RoutingTable* p) { p->__incRef(); } +void IceInternal::decRef(RoutingTable* p) { p->__decRef(); } + +IceInternal::RoutingTable::RoutingTable() : + _tableHint(_table.end()) +{ +} + +bool +IceInternal::RoutingTable::add(const ObjectPrx& prx) +{ + if (!prx) + { + return false; + } + + ObjectPrx proxy = prx->ice_default(); // We insert the proxy in it's default form into the routing table. + + IceUtil::Mutex::Lock sync(*this); + + map<Identity, ObjectPrx>::iterator p = _table.end(); + + if (_tableHint != _table.end()) + { + if (_tableHint->first == proxy->ice_getIdentity()) + { + p = _tableHint; + } + } + + if (p == _table.end()) + { + p = _table.find(proxy->ice_getIdentity()); + } + + if (p == _table.end()) + { + _tableHint = _table.insert(_tableHint, make_pair(proxy->ice_getIdentity(), proxy)); + return true; + } + else + { + return false; + } +} + +ObjectPrx +IceInternal::RoutingTable::get(const Identity& ident) +{ + if (ident.name.empty()) + { + return 0; + } + + IceUtil::Mutex::Lock sync(*this); + + map<Identity, ObjectPrx>::iterator p = _table.end(); + + if (_tableHint != _table.end()) + { + if (_tableHint->first == ident) + { + p = _tableHint; + } + } + + if (p == _table.end()) + { + p = _table.find(ident); + } + + if (p == _table.end()) + { + return 0; + } + else + { + _tableHint = p; + return p->second; + } +} |