|
|
|
|
@ -3,9 +3,8 @@
|
|
|
|
|
Dispatcher::Dispatcher() { |
|
|
|
|
connection=dispatcher.connect([this] { |
|
|
|
|
std::unique_lock<std::mutex> lock(functions_mutex); |
|
|
|
|
for(auto &function: functions) { |
|
|
|
|
for(auto &function: functions) |
|
|
|
|
function(); |
|
|
|
|
} |
|
|
|
|
functions.clear(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
@ -16,14 +15,6 @@ Dispatcher::~Dispatcher() {
|
|
|
|
|
functions.clear(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Dispatcher::post(std::function<void()> &&function) { |
|
|
|
|
{ |
|
|
|
|
std::unique_lock<std::mutex> lock(functions_mutex); |
|
|
|
|
functions.emplace_back(function); |
|
|
|
|
} |
|
|
|
|
dispatcher(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Dispatcher::disconnect() { |
|
|
|
|
connection.disconnect(); |
|
|
|
|
} |
|
|
|
|
|