Run clang-format
This commit is contained in:
@@ -1,40 +1,41 @@
|
||||
#include <deque>
|
||||
#include <mutex>
|
||||
#include <future>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
|
||||
std::mutex m;
|
||||
std::deque<std::packaged_task<void()> > tasks;
|
||||
std::deque<std::packaged_task<void()>> tasks;
|
||||
|
||||
bool gui_shutdown_message_received();
|
||||
void get_and_process_gui_message();
|
||||
|
||||
void gui_thread()
|
||||
void
|
||||
gui_thread()
|
||||
{
|
||||
while(!gui_shutdown_message_received())
|
||||
while (!gui_shutdown_message_received()) {
|
||||
get_and_process_gui_message();
|
||||
std::packaged_task<void()> task;
|
||||
{
|
||||
get_and_process_gui_message();
|
||||
std::packaged_task<void()> task;
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(m);
|
||||
if(tasks.empty())
|
||||
continue;
|
||||
task=std::move(tasks.front());
|
||||
tasks.pop_front();
|
||||
}
|
||||
task();
|
||||
std::lock_guard<std::mutex> lk(m);
|
||||
if (tasks.empty())
|
||||
continue;
|
||||
task = std::move(tasks.front());
|
||||
tasks.pop_front();
|
||||
}
|
||||
task();
|
||||
}
|
||||
}
|
||||
|
||||
std::thread gui_bg_thread(gui_thread);
|
||||
|
||||
template<typename Func>
|
||||
std::future<void> post_task_for_gui_thread(Func f)
|
||||
template <typename Func>
|
||||
std::future<void>
|
||||
post_task_for_gui_thread(Func f)
|
||||
{
|
||||
std::packaged_task<void()> task(f);
|
||||
std::future<void> res=task.get_future();
|
||||
std::lock_guard<std::mutex> lk(m);
|
||||
tasks.push_back(std::move(task));
|
||||
return res;
|
||||
std::packaged_task<void()> task(f);
|
||||
std::future<void> res = task.get_future();
|
||||
std::lock_guard<std::mutex> lk(m);
|
||||
tasks.push_back(std::move(task));
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user