1 #ifndef TERMOX_SYSTEM_EVENT_LOOP_HPP
2 #define TERMOX_SYSTEM_EVENT_LOOP_HPP
8 #include <termox/system/event_queue.hpp>
23 auto run(F loop_function) ->
int
31 loop_function(queue_);
47 fut_ = std::async(std::launch::async, [
this, loop_function] {
48 return this->
run(std::move(loop_function));
59 void exit(
int return_code);
71 [[nodiscard]] auto
exit_flag() const ->
bool;
80 std::future<
int> fut_;
82 std::atomic<
bool> running_ = false;
83 std::atomic<
bool> exit_ = false;
Calls on loop_function(), and then processes the Event_queue.
Definition: event_loop.hpp:17
auto run(F loop_function) -> int
Start the event loop, calling loop_function on each iteration.
Definition: event_loop.hpp:23
void run_async(F &&loop_function)
Start the event loop in a separate thread.
Definition: event_loop.hpp:43
auto exit_flag() const -> bool
Return true if the exit flag has been set.
Definition: event_loop.cpp:20
auto event_queue() -> Event_queue &
Return a reference to the Event_queue of this loop.
Definition: event_loop.cpp:22
auto wait() -> int
Block until the async event loop returns.
Definition: event_loop.cpp:11
auto is_running() const -> bool
Return true if the event loop is currently running.
Definition: event_loop.cpp:18
void exit(int return_code)
Call on the loop to exit at the next exit point.
Definition: event_loop.cpp:5
Definition: event_queue.hpp:63
void send_all()
Send all events, then flush the screen if any events were actually sent.
Definition: event_queue.cpp:84