summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2004-03-01 18:05:23 +0000
committerBernard Normier <bernard@zeroc.com>2004-03-01 18:05:23 +0000
commit153bc8421cd83ad08e8b161e393c065b187c6807 (patch)
tree5652f2b1ae2836ff88ffab1ae57779b4e1c49f4c /cpp/src
parentminor changes (diff)
downloadice-153bc8421cd83ad08e8b161e393c065b187c6807.tar.bz2
ice-153bc8421cd83ad08e8b161e393c065b187c6807.tar.xz
ice-153bc8421cd83ad08e8b161e393c065b187c6807.zip
Cached persistent link dictionary
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IceStorm/TopicI.cpp52
-rw-r--r--cpp/src/IceStorm/TopicI.h3
2 files changed, 22 insertions, 33 deletions
diff --git a/cpp/src/IceStorm/TopicI.cpp b/cpp/src/IceStorm/TopicI.cpp
index bcc3841598c..7b8c7f16753 100644
--- a/cpp/src/IceStorm/TopicI.cpp
+++ b/cpp/src/IceStorm/TopicI.cpp
@@ -21,11 +21,9 @@
#include <Freeze/Initialize.h>
#include <algorithm>
-
using namespace IceStorm;
using namespace std;
-
namespace IceStorm
{
@@ -304,7 +302,8 @@ TopicI::TopicI(const Ice::ObjectAdapterPtr& adapter, const TraceLevelsPtr& trace
_factory(factory),
_destroyed(false),
_connection(Freeze::createConnection(adapter->getCommunicator(), envName)),
- _topics(_connection, dbName, false)
+ _topics(_connection, dbName, false),
+ _links(links)
{
_subscribers = new TopicSubscribers(_traceLevels);
@@ -333,7 +332,7 @@ TopicI::TopicI(const Ice::ObjectAdapterPtr& adapter, const TraceLevelsPtr& trace
//
// Re-establish linked subscribers.
//
- for(LinkRecordDict::const_iterator p = links.begin(); p != links.end(); ++p)
+ for(LinkRecordDict::const_iterator p = _links.begin(); p != _links.end(); ++p)
{
if(_traceLevels->topic > 0)
{
@@ -489,7 +488,6 @@ TopicI::link(const TopicPrx& topic, Ice::Int cost, const Ice::Current&)
out << _name << " link " << name << " cost " << cost;
}
-
//
// Retrieve the TopicLink.
//
@@ -497,13 +495,7 @@ TopicI::link(const TopicPrx& topic, Ice::Int cost, const Ice::Current&)
TopicLinkPrx link = internal->getLinkProxy();
Ice::Identity ident = link->ice_getIdentity();
-
- PersistentTopicMap::const_iterator p = _topics.find(_name);
- assert(p != _topics.end());
-
- LinkRecordDict links = p->second;
-
- if(links.find(name) != links.end())
+ if(_links.find(name) != _links.end())
{
LinkExists ex;
ex.name = name;
@@ -517,9 +509,12 @@ TopicI::link(const TopicPrx& topic, Ice::Int cost, const Ice::Current&)
record.obj = link;
record.cost = cost;
record.theTopic = topic;
- links.insert(LinkRecordDict::value_type(name, record));
+ _links.insert(LinkRecordDict::value_type(name, record));
- _topics.put(PersistentTopicMap::value_type(_name, links));
+ //
+ // Save
+ //
+ _topics.put(PersistentTopicMap::value_type(_name, _links));
//
// Create the subscriber object and add it to the set of subscribers.
@@ -544,13 +539,9 @@ TopicI::unlink(const TopicPrx& topic, const Ice::Current&)
TopicInternalPrx internal = TopicInternalPrx::checkedCast(topic);
Ice::ObjectPrx link = internal->getLinkProxy();
- PersistentTopicMap::const_iterator p = _topics.find(_name);
- assert(p != _topics.end());
-
- LinkRecordDict links = p->second;
- LinkRecordDict::iterator q = links.find(name);
+ LinkRecordDict::iterator q = _links.find(name);
- if(q == links.end())
+ if(q == _links.end())
{
if(_traceLevels->topic > 0)
{
@@ -564,8 +555,12 @@ TopicI::unlink(const TopicPrx& topic, const Ice::Current&)
}
else
{
- links.erase(q);
- _topics.put(PersistentTopicMap::value_type(_name, links));
+ _links.erase(q);
+
+ //
+ // Save
+ //
+ _topics.put(PersistentTopicMap::value_type(_name, _links));
if(_traceLevels->topic > 0)
{
@@ -589,13 +584,9 @@ TopicI::getLinkInfoSeq(const Ice::Current&) const
TopicI* const This = const_cast<TopicI* const>(this);
This->reap();
- PersistentTopicMap::const_iterator p = _topics.find(_name);
- assert(p != _topics.end());
- LinkRecordDict links = p->second;
-
LinkInfoSeq seq;
- for(LinkRecordDict::const_iterator q = links.begin(); q != links.end(); ++q)
+ for(LinkRecordDict::const_iterator q = _links.begin(); q != _links.end(); ++q)
{
LinkInfo info;
info.name = q->first;
@@ -631,9 +622,6 @@ TopicI::reap()
return;
}
- PersistentTopicMap::const_iterator p = _topics.find(_name);
- assert(p != _topics.end());
- LinkRecordDict links = p->second;
bool updated = false;
//
@@ -647,7 +635,7 @@ TopicI::reap()
assert(subscriber->error());
if(subscriber->persistent())
{
- if(links.erase(subscriber->id().category) > 0)
+ if(_links.erase(subscriber->id().category) > 0)
{
updated = true;
if(_traceLevels->topic > 0)
@@ -669,6 +657,6 @@ TopicI::reap()
if(updated)
{
- _topics.put(PersistentTopicMap::value_type(_name, links));
+ _topics.put(PersistentTopicMap::value_type(_name, _links));
}
}
diff --git a/cpp/src/IceStorm/TopicI.h b/cpp/src/IceStorm/TopicI.h
index 34f5c35c30b..5e75fd03e20 100644
--- a/cpp/src/IceStorm/TopicI.h
+++ b/cpp/src/IceStorm/TopicI.h
@@ -118,7 +118,8 @@ private:
TopicSubscribersPtr _subscribers; // Set of Subscribers
Freeze::ConnectionPtr _connection;
- PersistentTopicMap _topics;
+ PersistentTopicMap _topics;
+ LinkRecordDict _links;
};
typedef IceUtil::Handle<TopicI> TopicIPtr;