From 782e17f05a6ba3868739fa7d9e744acb73031dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=BB=E9=AD=82=E5=9C=A3=E4=BD=BF?= Date: Tue, 23 Jan 2024 16:55:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=86=E5=88=86=E5=87=BAbind=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/Timer.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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; }