[asterisk-scf-commits] asterisk-scf/release/ice-util-cpp.git branch "storage" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Mon Dec 13 16:05:33 CST 2010
branch "storage" has been updated
via fbf4e9c0877907e57e560bcd435c71a3eeb7a15a (commit)
from d9c73dc1df2b1e4d41b033d3f0f2bee34b141d65 (commit)
Summary of changes:
.../src/MemcachedStateReplicatorStorage.h | 40 +++++++-------------
1 files changed, 14 insertions(+), 26 deletions(-)
- Log -----------------------------------------------------------------
commit fbf4e9c0877907e57e560bcd435c71a3eeb7a15a
Author: Mark Michelson <mmichelson at digium.com>
Date: Mon Dec 13 16:11:11 2010 -0600
Switch from using a for_each construct with functor to using a for loop.
diff --git a/StateReplicator/src/MemcachedStateReplicatorStorage.h b/StateReplicator/src/MemcachedStateReplicatorStorage.h
index 65a4e73..4865aab 100644
--- a/StateReplicator/src/MemcachedStateReplicatorStorage.h
+++ b/StateReplicator/src/MemcachedStateReplicatorStorage.h
@@ -48,7 +48,15 @@ public:
: mConfig(config), mCommunicator(communicator) { }
void set(const std::vector<S> &items)
{
- std::for_each(items.begin(), items.end(), SetFunctor<S>(mCommunicator, mConfig->getMemcached()));
+ for (typename std::vector<S>::const_iterator iter = items.begin();
+ iter != items.end(); ++iter)
+ {
+ //First we need to serialize the object.
+ std::vector<Ice::Byte> stream;
+ serialize(*iter, stream);
+ //Now we send the data off to memcached.
+ memcached_set(mConfig->getMemcached(), (*iter)->key, (*iter)->key.size(), &stream[0], stream.size(), 0, 0);
+ }
}
std::vector<S> get(const std::vector<K> &keys)
{
@@ -72,32 +80,12 @@ public:
private:
MemcachedStateReplicatorStorageConfigPtr mConfig;
Ice::CommunicatorPtr mCommunicator;
-
- template<class T>
- class SetFunctor
+ void serialize(S x, std::vector<Ice::Byte> &stream)
{
- public:
- SetFunctor(Ice::CommunicatorPtr communicator, memcached_st *memc)
- : mCommunicator(communicator), mMemc(memc) { }
- ~SetFunctor() { }
- void operator() (T x)
- {
- //First we need to serialize the object.
- std::vector<Ice::Byte> stream;
- serialize(x, stream);
- //Now we send the data off to memcached.
- memcached_set(mMemc, x->key, x->key.size(), &stream[0], stream.size(), 0, 0);
- }
- private:
- Ice::CommunicatorPtr mCommunicator;
- memcached_st *mMemc;
- void serialize(T x, std::vector<Ice::Byte> &stream)
- {
- Ice::OutputStreamPtr out = Ice::createOutputStream(mCommunicator);
- out->write(x);
- out->finished(stream);
- }
- };
+ Ice::OutputStreamPtr out = Ice::createOutputStream(mCommunicator);
+ out->write(x);
+ out->finished(stream);
+ }
};
};
-----------------------------------------------------------------------
--
asterisk-scf/release/ice-util-cpp.git
More information about the asterisk-scf-commits
mailing list