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.
This commit is contained in:
Johan Wikman 2018-04-20 14:48:11 +03:00
parent cbd7e51dd8
commit ac7d1198fb
2 changed files with 21 additions and 18 deletions

View File

@ -952,7 +952,8 @@ public:
*/
template<class D>
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<D>(delay, pFunction, data));
}
@ -978,10 +979,10 @@ public:
*/
template<class T>
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<T>(delay, pT, pMethod));
return add_delayed_call(new DelayedCallMethodVoid<T>(delay, pMethod, pT));
}
/**
@ -1006,10 +1007,11 @@ public:
*/
template<class T, class D>
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<T, D>(delay, pT, pMethod, data));
return add_delayed_call(new DelayedCallMethod<T, D>(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);

View File

@ -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();