From d1f0d156a7798b542763c3348d837e75d55d1bf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= Date: Thu, 4 Jul 2019 12:56:09 +0300 Subject: [PATCH] libcore|EventLoop: Event loop callback utility --- doomsday/libs/core/include/de/core/eventloop.h | 1 + doomsday/libs/core/src/core/eventloop.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/doomsday/libs/core/include/de/core/eventloop.h b/doomsday/libs/core/include/de/core/eventloop.h index 83870b8369..72666ba05f 100644 --- a/doomsday/libs/core/include/de/core/eventloop.h +++ b/doomsday/libs/core/include/de/core/eventloop.h @@ -80,6 +80,7 @@ class DE_PUBLIC EventLoop public: static void post(Event *event); + static void callback(const std::function &); private: DE_PRIVATE(d) diff --git a/doomsday/libs/core/src/core/eventloop.cpp b/doomsday/libs/core/src/core/eventloop.cpp index 05b7985c8b..2eab627185 100644 --- a/doomsday/libs/core/src/core/eventloop.cpp +++ b/doomsday/libs/core/src/core/eventloop.cpp @@ -190,6 +190,11 @@ void EventLoop::post(Event *event) // static } } +void EventLoop::callback(const std::function &func) // static +{ + post(new CoreEvent(func)); +} + EventLoop *EventLoop::get() { using namespace internal;