diff --git a/include/Timer.h b/include/Timer.h index a55005c..801ac0a 100644 --- a/include/Timer.h +++ b/include/Timer.h @@ -47,9 +47,12 @@ namespace ling { public: - template - explicit Timer(F &&f, Args &&...args) { + explicit Timer() { this->id = nextId++; + } + + template + Timer &bind(F &&f, Args &&...args) { std::function func = std::bind(std::forward(f), std::forward( args)...); // 连接函数和参数定义,特殊函数类型,避免左右值错误 auto task_ptr = std::make_shared>(func); @@ -69,6 +72,7 @@ namespace ling { }; task.fun = warpper_func; task.id = this->id; + return *this; }