mirror of https://gitlab.com/cppit/jucipp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
525 B
28 lines
525 B
|
8 years ago
|
#pragma once
|
||
|
10 years ago
|
#include <gtkmm.h>
|
||
|
|
#include <mutex>
|
||
|
8 years ago
|
#include <functional>
|
||
|
8 years ago
|
#include <list>
|
||
|
10 years ago
|
|
||
|
|
class Dispatcher {
|
||
|
|
private:
|
||
|
8 years ago
|
std::list<std::function<void()>> functions;
|
||
|
10 years ago
|
std::mutex functions_mutex;
|
||
|
|
Glib::Dispatcher dispatcher;
|
||
|
|
sigc::connection connection;
|
||
|
|
public:
|
||
|
|
Dispatcher();
|
||
|
|
~Dispatcher();
|
||
|
8 years ago
|
|
||
|
|
template<typename T>
|
||
|
|
void post(T &&function) {
|
||
|
|
{
|
||
|
|
std::unique_lock<std::mutex> lock(functions_mutex);
|
||
|
|
functions.emplace_back(std::forward<T>(function));
|
||
|
|
}
|
||
|
|
dispatcher();
|
||
|
|
}
|
||
|
|
|
||
|
10 years ago
|
void disconnect();
|
||
|
|
};
|