From ac7d1198fbaa25acda17a9f3a0b90ebf72273e18 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Fri, 20 Apr 2018 14:48:11 +0300 Subject: [PATCH] MXS-1754 Alter order of parameters When providing pointer to instance and pointer to member function of the class of the instance, the pointer to the member function should be first and the pointer to the instance second. --- server/core/internal/worker.hh | 29 ++++++++++++++++------------- server/core/test/test_worker.cc | 10 +++++----- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/server/core/internal/worker.hh b/server/core/internal/worker.hh index 61c60f128..789a35ae5 100644 --- a/server/core/internal/worker.hh +++ b/server/core/internal/worker.hh @@ -952,7 +952,8 @@ public: */ template uint32_t delayed_call(int32_t delay, - bool (*pFunction)(Worker::Call::action_t action, D data), D data) + bool (*pFunction)(Worker::Call::action_t action, D data), + D data) { return add_delayed_call(new DelayedCallFunction(delay, pFunction, data)); } @@ -978,10 +979,10 @@ public: */ template uint32_t delayed_call(int32_t delay, - T* pT, - bool (T::*pMethod)(Worker::Call::action_t action)) + bool (T::*pMethod)(Worker::Call::action_t action), + T* pT) { - return add_delayed_call(new DelayedCallMethodVoid(delay, pT, pMethod)); + return add_delayed_call(new DelayedCallMethodVoid(delay, pMethod, pT)); } /** @@ -1006,10 +1007,11 @@ public: */ template uint32_t delayed_call(int32_t delay, + bool (T::*pMethod)(Worker::Call::action_t action, D data), T* pT, - bool (T::*pMethod)(Worker::Call::action_t action, D data), D data) + D data) { - return add_delayed_call(new DelayedCallMethod(delay, pT, pMethod, data)); + return add_delayed_call(new DelayedCallMethod(delay, pMethod, pT, data)); } /** @@ -1196,11 +1198,12 @@ private: public: DelayedCallMethod(int32_t delay, + bool (T::*pMethod)(Worker::Call::action_t action, D data), T* pT, - bool (T::*pMethod)(Worker::Call::action_t action, D data), D data) + D data) : DelayedCall(delay) - , m_pT(pT) , m_pMethod(pMethod) + , m_pT(pT) , m_data(data) { } @@ -1212,8 +1215,8 @@ private: } private: - T* m_pT; bool (T::*m_pMethod)(Worker::Call::action_t, D); + T* m_pT; D m_data; }; @@ -1225,11 +1228,11 @@ private: public: DelayedCallMethodVoid(int32_t delay, - T* pT, - bool (T::*pMethod)(Worker::Call::action_t)) + bool (T::*pMethod)(Worker::Call::action_t), + T* pT) : DelayedCall(delay) - , m_pT(pT) , m_pMethod(pMethod) + , m_pT(pT) { } @@ -1240,8 +1243,8 @@ private: } private: - T* m_pT; bool (T::*m_pMethod)(Worker::Call::action_t); + T* m_pT; }; uint32_t add_delayed_call(DelayedCall* pDelayed_call); diff --git a/server/core/test/test_worker.cc b/server/core/test/test_worker.cc index 202e9dc7d..697e529f3 100644 --- a/server/core/test/test_worker.cc +++ b/server/core/test/test_worker.cc @@ -129,11 +129,11 @@ int run() TimerTest t4(&rv, 500); TimerTest t5(&rv, 600); - w.delayed_call(t1.delay(), &t1, &TimerTest::tick); - w.delayed_call(t2.delay(), &t2, &TimerTest::tick); - w.delayed_call(t3.delay(), &t3, &TimerTest::tick); - w.delayed_call(t4.delay(), &t4, &TimerTest::tick); - w.delayed_call(t5.delay(), &t5, &TimerTest::tick); + w.delayed_call(t1.delay(), &TimerTest::tick, &t1); + w.delayed_call(t2.delay(), &TimerTest::tick, &t2); + w.delayed_call(t3.delay(), &TimerTest::tick, &t3); + w.delayed_call(t4.delay(), &TimerTest::tick, &t4); + w.delayed_call(t5.delay(), &TimerTest::tick, &t5); w.run();