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.
26 lines
503 B
26 lines
503 B
#pragma once |
|
#include <gtkmm.h> |
|
#include <mutex> |
|
#include <list> |
|
|
|
class Dispatcher { |
|
private: |
|
std::list<std::function<void()>> functions; |
|
std::mutex functions_mutex; |
|
Glib::Dispatcher dispatcher; |
|
sigc::connection connection; |
|
public: |
|
Dispatcher(); |
|
~Dispatcher(); |
|
|
|
template<typename T> |
|
void post(T &&function) { |
|
{ |
|
std::unique_lock<std::mutex> lock(functions_mutex); |
|
functions.emplace_back(std::forward<T>(function)); |
|
} |
|
dispatcher(); |
|
} |
|
|
|
void disconnect(); |
|
};
|
|
|