Skip to content

Commit

Permalink
Fix compilation of marl::Ticket::onCall()
Browse files Browse the repository at this point in the history
This template method is not tested by our unit tests, and did not compile when used.

This was broken by 08a8201.
  • Loading branch information
ben-clayton committed Mar 16, 2020
1 parent e9f3126 commit 575b61e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions include/marl/ticket.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class Ticket {
struct Record;

public:
using OnCall = std::function<void()>;

// Queue hands out Tickets.
class Queue {
public:
Expand Down Expand Up @@ -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 <typename F>
inline void onCall(F&& f) const;

Expand All @@ -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<bool> isDone = {false};
};
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -228,13 +230,13 @@ void Ticket::Record::callAndUnlock(std::unique_lock<std::mutex>& 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));
}
}

Expand Down

0 comments on commit 575b61e

Please sign in to comment.