From 575b61e76526f8a6f64d19f12f718043728b8e4e Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Mon, 16 Mar 2020 20:16:41 +0000 Subject: [PATCH] Fix compilation of marl::Ticket::onCall() This template method is not tested by our unit tests, and did not compile when used. This was broken by 08a8201712. --- include/marl/ticket.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/include/marl/ticket.h b/include/marl/ticket.h index 10c2b77..59a38fc 100644 --- a/include/marl/ticket.h +++ b/include/marl/ticket.h @@ -62,6 +62,8 @@ class Ticket { struct Record; public: + using OnCall = std::function; + // Queue hands out Tickets. class Queue { public: @@ -93,7 +95,7 @@ class Ticket { // onCall() registers the function f to be invoked when this ticket is // called. If the ticket is already called prior to calling onCall(), then // f() will be executed immediately. - // F must be a function of the signature: void F() + // F must be a function of the OnCall signature. template inline void onCall(F&& f) const; @@ -111,7 +113,7 @@ class Ticket { Record* next = nullptr; // guarded by shared->mutex Record* prev = nullptr; // guarded by shared->mutex inline void unlink(); // guarded by shared->mutex - Task onCall; // guarded by shared->mutex + OnCall onCall; // guarded by shared->mutex bool isCalled = false; // guarded by shared->mutex std::atomic isDone = {false}; }; @@ -155,7 +157,7 @@ void Ticket::onCall(Function&& f) const { a(); b(); } - Task a, b; + OnCall a, b; }; record->onCall = std::move(Joined{std::move(record->onCall), std::move(f)}); } else { @@ -228,13 +230,13 @@ void Ticket::Record::callAndUnlock(std::unique_lock& lock) { return; } isCalled = true; - Task task; - std::swap(task, onCall); + OnCall callback; + std::swap(callback, onCall); isCalledCondVar.notify_all(); lock.unlock(); - if (task) { - marl::schedule(std::move(task)); + if (callback) { + marl::schedule(std::move(callback)); } }