OSDN Git Service

任意メソッドの呼び出しにも対応!
authorMyun2 <myun2@nwhite.info>
Sun, 4 Jul 2010 05:10:17 +0000 (14:10 +0900)
committerMyun2 <myun2@nwhite.info>
Sun, 4 Jul 2010 05:10:17 +0000 (14:10 +0900)
roast/include/roast/thread/thread.hpp

index 5216c40..c05078a 100644 (file)
@@ -180,11 +180,18 @@ namespace roast
                }
                
                template <typename T>
-               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 <typename T>
+               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 <typename T>
-               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 <typename T>
+               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<T>,
+                               _thread_class_internal_callback<T>,
                                (int)new _thread_start_class_info<T>(ptr, func, param, false),
                                opt);
                        if ( m_handle == NULL )