
I want co call a function or method in a separate thread periodically. Therefore my CCycleThread class starts the execute method as thread and calls the user function object in a loop. The user can pause, resume and finish the thread if he wishes. To separate the worker code from the threading code I build this wrapper around boost thread with pause and resume methods.
<...> Yes, I understand why such a design can be uselful. What I said is that I didn't realise how to separate binder/not-a-binder cases. But after thinking a bit... actually, you can just define 2 function templates in a straight-forward way: // simple functor/function case template<typename T> CCycleThread(T t) { m_thread.reset(new boost::thread(boost::bind(&CCycleThread::execute<T>, this, t))); } // binder case template<class R, class F, class L> CCycleThread(boost::_bi::bind_t<R,F,L> t) { m_thread.reset(new boost::thread(boost::bind(&CCycleThread::execute<boost::_bi::protected_bind_t<boost::_bi::bind_t<R,F,L>
, this, boost::protect(t)))); }