diff --git a/lib_acl_cpp/include/acl_cpp/stdlib/thread.hpp b/lib_acl_cpp/include/acl_cpp/stdlib/thread.hpp index 1bda6ed49..30b6d521f 100644 --- a/lib_acl_cpp/include/acl_cpp/stdlib/thread.hpp +++ b/lib_acl_cpp/include/acl_cpp/stdlib/thread.hpp @@ -19,6 +19,13 @@ public: * @return {void*} 线程退出前返回的参数 */ virtual void* run(void) = 0; + + /** + * 虚方法,在新创建的子线程中的 run() 方法被调用前调用,在同步创建 + * 线程方式下,子线程被创建后调用该虚方法,然后再通知创建这线程, + * 从而保证在创建线程的 start() 方法返回前子线程执行初始化过程。 + */ + virtual void init(void) {} }; template class tbox; diff --git a/lib_acl_cpp/lib_acl_cpp_vc2017.rc b/lib_acl_cpp/lib_acl_cpp_vc2017.rc index 212b17e3e..d824b997a 100644 --- a/lib_acl_cpp/lib_acl_cpp_vc2017.rc +++ b/lib_acl_cpp/lib_acl_cpp_vc2017.rc @@ -27,7 +27,7 @@ 1 TEXTINCLUDE BEGIN - "resource_vc2015.h\0" + "resource_vc2017.h\0" END 2 TEXTINCLUDE diff --git a/lib_acl_cpp/src/stdlib/thread.cpp b/lib_acl_cpp/src/stdlib/thread.cpp index 9070aa483..ee1a251f3 100644 --- a/lib_acl_cpp/src/stdlib/thread.cpp +++ b/lib_acl_cpp/src/stdlib/thread.cpp @@ -87,6 +87,9 @@ void* thread::thread_run(void* arg) break; } } + + thr->init(); + thr->sync_->push(NULL); // 如果线程创建时为分离模式,则当 run 运行时用户有可能