diff options
author | Alan Conway <aconway@apache.org> | 2007-08-21 23:35:23 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2007-08-21 23:35:23 +0000 |
commit | af1fa9365f9166e129bbcc44c0706e41c9afa775 (patch) | |
tree | e351341d93e1f1ec1c843307c1e132ec856186b4 /qpid/cpp/src/tests/Serializer.cpp | |
parent | 05fe12bb0ba1bcdb7e608567f1f8baeaf3f3431b (diff) | |
download | qpid-python-af1fa9365f9166e129bbcc44c0706e41c9afa775.tar.gz |
* src/qpid/sys/Serializer.h, .cpp:
Template Serializer on functor for execute().
Old Serializer equivalent to Serializer<boost::function<void()> >
* src/qpid/broker/BrokerQueue.h, .cpp:
Use hand-written functor for Serializer instead of boost::function.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@568332 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests/Serializer.cpp')
-rw-r--r-- | qpid/cpp/src/tests/Serializer.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/qpid/cpp/src/tests/Serializer.cpp b/qpid/cpp/src/tests/Serializer.cpp index d7345acf06..0135822275 100644 --- a/qpid/cpp/src/tests/Serializer.cpp +++ b/qpid/cpp/src/tests/Serializer.cpp @@ -38,6 +38,7 @@ using namespace qpid::sys; using namespace qpid::framing; using namespace std; +typedef Serializer<boost::function<void()> > BoostFunctionSerializer; /** Test for concurrent calls */ struct Tester { @@ -61,7 +62,7 @@ struct Tester { } }; -void execute(Serializer& s, Serializer::Task t) +void execute(BoostFunctionSerializer& s, boost::function<void()> t) { s.execute(t); } @@ -69,7 +70,7 @@ void execute(Serializer& s, Serializer::Task t) BOOST_AUTO_TEST_CASE(testSingleThread) { // Verify that we call in the same thread by default. Tester tester; - Serializer s; + BoostFunctionSerializer s; for (int i = 0; i < 100; ++i) execute(s, boost::bind(&Tester::test, &tester)); // All should be executed in this thread. @@ -83,7 +84,7 @@ BOOST_AUTO_TEST_CASE(testSingleThread) { BOOST_AUTO_TEST_CASE(testSingleThreadNoImmediate) { // Verify that we call in different thread if immediate=false. Tester tester; - Serializer s(false); + BoostFunctionSerializer s(false); for (int i = 0; i < 100; ++i) execute(s, boost::bind(&Tester::test, &tester)); { @@ -99,13 +100,13 @@ BOOST_AUTO_TEST_CASE(testSingleThreadNoImmediate) { } struct Caller : public Runnable, public Tester { - Caller(Serializer& s) : serializer(s) {} + Caller(BoostFunctionSerializer& s) : serializer(s) {} void run() { execute(serializer, boost::bind(&Tester::test, this)); } - Serializer& serializer; + BoostFunctionSerializer& serializer; }; BOOST_AUTO_TEST_CASE(testDispatchThread) { - Serializer s; + BoostFunctionSerializer s; Caller caller(s); Thread threads[100]; // Concurrent calls. @@ -121,7 +122,7 @@ BOOST_AUTO_TEST_CASE(testDispatchThread) { } -std::auto_ptr<Serializer> serializer; +std::auto_ptr<BoostFunctionSerializer> serializer; struct CallDispatch : public Runnable { void run() { @@ -136,7 +137,7 @@ void notifyDispatch() { // Use externally created threads. BOOST_AUTO_TEST_CASE(testExternalDispatch) { - serializer.reset(new Serializer(false, ¬ifyDispatch)); + serializer.reset(new BoostFunctionSerializer(false, ¬ifyDispatch)); Tester tester; for (int i = 0; i < 100; ++i) execute(*serializer, boost::bind(&Tester::test, &tester)); |