From 46a5045956a821c33aea7a98681fb388e0f4b64c Mon Sep 17 00:00:00 2001 From: randomdan Date: Thu, 1 Sep 2011 23:19:14 +0000 Subject: Allow low preference caches to refill higher ones --- project2/common/cache.cpp | 2 +- project2/common/rowProcessor.cpp | 23 +++++++++++++---------- project2/common/rowProcessor.h | 4 +++- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/project2/common/cache.cpp b/project2/common/cache.cpp index 1c078fb..7ad4053 100644 --- a/project2/common/cache.cpp +++ b/project2/common/cache.cpp @@ -17,7 +17,7 @@ bool Cache::checkAndExecute(const Glib::ustring & n, const Glib::ustring & f, co RowSetCPtr cached = getCachedRowSet(n, f, rp); if (cached) { try { - Logger()->messagef(LOG_ERR, "Executing from cache"); + Logger()->messagef(LOG_DEBUG, "Executing from cache '%s'", name.c_str()); cached->execute(f, rp); return true; } diff --git a/project2/common/rowProcessor.cpp b/project2/common/rowProcessor.cpp index 8161aaf..71fdd76 100644 --- a/project2/common/rowProcessor.cpp +++ b/project2/common/rowProcessor.cpp @@ -28,30 +28,33 @@ RowProcessor::execute() const ScopeObject _ihp(boost::bind(&IHaveParameters::pop, this)); BOOST_FOREACH(const CachePtr & c, caches) { if (c->checkAndExecute(source->name, filter, this)) { + BOOST_FOREACH(const TargetCaches::value_type & c, tc) { + c->get<1>()->close(source->name, filter, this); + } + tc.clear(); return; } - } - BOOST_FOREACH(const CachePtr & c, caches) { PresenterPtr p = c->openFor(source->name, filter, this); if (p) { - tc.insert(p); + tc.insert(TargetCachePtr(new TargetCache(p, c))); } } + Logger()->messagef(LOG_DEBUG, "Executing from source '%s'", source->name.c_str()); source->execute(filter, this); - tc.clear(); - BOOST_FOREACH(const CachePtr & c, caches) { - c->close(source->name, filter, this); + BOOST_FOREACH(const TargetCaches::value_type & c, tc) { + c->get<1>()->close(source->name, filter, this); } + tc.clear(); } void RowProcessor::rowReadyInternal(const RowState * rs) const { BOOST_FOREACH(const TargetCaches::value_type & c, tc) { - c->pushSub(filter.empty() ? "row" : filter); - rs->foreachColumn(boost::bind(&Presenter::addField, c, _2, _3)); - rs->foreachAttr(boost::bind(&Presenter::addAttr, c, _1, _2)); - c->popSub(); + c->get<0>()->pushSub(filter.empty() ? "row" : filter); + rs->foreachColumn(boost::bind(&Presenter::addField, c->get<0>(), _2, _3)); + rs->foreachAttr(boost::bind(&Presenter::addAttr, c->get<0>(), _1, _2)); + c->get<0>()->popSub(); } rowReady(rs); } diff --git a/project2/common/rowProcessor.h b/project2/common/rowProcessor.h index c25dc73..3f39d19 100644 --- a/project2/common/rowProcessor.h +++ b/project2/common/rowProcessor.h @@ -29,7 +29,9 @@ class RowProcessor : public IHaveParameters { virtual void rowReady(const RowState *) const = 0; typedef ANONORDEREDSTORAGEOF(Cache) Caches; Caches caches; - typedef std::set TargetCaches; + typedef boost::tuple TargetCache; + typedef boost::shared_ptr TargetCachePtr; + typedef std::set TargetCaches; mutable TargetCaches tc; }; -- cgit v1.2.3