From: Myun2 Date: Sun, 4 Jul 2010 05:10:17 +0000 (+0900) Subject: 任意メソッドの呼び出しにも対応! X-Git-Tag: 20111130_shapeup_prev~273^2^2~2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=7de243511f08a53cb22e90d1fd1b771d1ae5ed4e;p=roast%2Froast.git 任意メソッドの呼び出しにも対応! --- diff --git a/roast/include/roast/thread/thread.hpp b/roast/include/roast/thread/thread.hpp index 5216c40f..c05078a1 100644 --- a/roast/include/roast/thread/thread.hpp +++ b/roast/include/roast/thread/thread.hpp @@ -180,11 +180,18 @@ namespace roast } template - thread_(T *ptr, roast_thread_func_t func, int param=0, void* opt=NULL) + thread_(int (T::*func)(int), T *ptr, int param=0, void* opt=NULL) { - if ( start_class_ptr(ptr,func,param,opt) != true ) + if ( start_class_ptr(func,ptr,param,opt) != true ) thread_exception("thread start failed."); } + + template + thread_(int (T::*func)(int), int param=0, void* opt=NULL) + { + // The second parameter is a class pointer or the method should be static. + The_second_parameter_is_a_class_pointer_or_the_method_should_be_static. + } virtual ~thread_() { @@ -221,10 +228,17 @@ namespace roast } template - bool start_class_ptr(T *ptr, roast_thread_func_t func, int param=0, void* opt=NULL) + bool start_class_ptr(int (T::*func)(int), int param=0, void* opt=NULL) + { + // The second parameter is a class pointer or the method should be static. + The_second_parameter_is_a_class_pointer_or_the_method_should_be_static. + } + + template + bool start_class_ptr(int (T::*func)(int), T *ptr, int param=0, void* opt=NULL) { m_handle = m_impl.start( - _thread_classptr_internal_callback, + _thread_class_internal_callback, (int)new _thread_start_class_info(ptr, func, param, false), opt); if ( m_handle == NULL )