From 19082449b9cc5f8004a9591af8e493c069671396 Mon Sep 17 00:00:00 2001 From: Determinant Date: Mon, 1 Jul 2019 02:40:45 -0400 Subject: better peer teardown --- include/salticidae/event.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'include/salticidae/event.h') diff --git a/include/salticidae/event.h b/include/salticidae/event.h index 78ae12d..30d8f3c 100644 --- a/include/salticidae/event.h +++ b/include/salticidae/event.h @@ -671,6 +671,7 @@ class ThreadCall { friend ThreadCall; public: Handle(): notifier(nullptr) {} + Handle(const Handle &) = delete; void exec() { callback(*this); if (notifier) @@ -707,16 +708,16 @@ class ThreadCall { } template - void async_call(Func callback) { + void async_call(Func &&callback) { auto h = new Handle(); - h->callback = callback; + h->callback = std::forward(callback); q.enqueue(h); } template - Result call(Func callback) { + Result call(Func &&callback) { auto h = new Handle(); - h->callback = callback; + h->callback = std::forward(callback); ThreadNotifier notifier; h->notifier = ¬ifier; q.enqueue(h); -- cgit v1.2.3