jubilant-funicular
|
#include <CallbackManager.h>
Classes | |
struct | event |
A function to run at a certain time with some regularity. More... | |
Static Public Member Functions | |
static uint64_t | setInterval (const Thunk &thunk, uint64_t when, uint64_t period) |
static uint64_t | setTimeout (const Thunk &thunk, uint64_t when) |
Schedules a function to be called once after when frames and then repeatedly after. | |
static bool | delay (uint64_t id, uint64_t when, bool absolute=true) |
Changes when an event is next scheduled to run. | |
static void | init () |
Initializes the CallbackManager. | |
static void | clear (uint64_t id) |
Removes the event with the given id. | |
static void | increment_frame () |
Informs CallbackManager that a frame has passed. | |
static void | destroy () |
Destroys the CallbackManager. | |
Static Private Member Functions | |
static void | dispatch () |
static void | dequeue (uint64_t id) |
Removes event from m_queue but not m_active (assumes id is valid) | |
Static Private Attributes | |
static std::map< uint64_t, event > | m_active |
The events waiting to happen (key is event.id) | |
static std::map< uint64_t, std::vector< event * > > | m_queue |
"Priority queue" of events ordered by when they should occur | |
static utils::ThreadPool | m_pool |
ThreadPool used for scheduling events to happen. | |
static std::thread | m_dispatcher |
Thread used to dispatch events. | |
static std::atomic< uint64_t > | m_next |
id given to the next created event | |
static std::mutex | m_mutex |
static std::condition_variable_any | m_cv |
static bool | m_working |
Global flag saying whether or not the CallbackManager has been destroyed. | |
static uint64_t | m_curr_frame |
The current frame. | |
Allows scheduling of functions to be called at a later point in time
Add ability to base timing off of actual time instead of frames
make non-static (ideally, one CallbackManager per ScreenManager)
Definition at line 12 of file CallbackManager.h.
struct nta::CallbackManager::event |
A function to run at a certain time with some regularity.
Definition at line 15 of file CallbackManager.h.
Class Members | ||
---|---|---|
uint64_t | id | id of event |
uint64_t | period | How many frames between consecutive runs. |
Thunk | thunk | Function to execute. |
uint64_t | when | How many frames to run it in. |
|
staticprivate |
Function run by m_dispatcher Handles calling of the various events at the right times
Definition at line 56 of file CallbackManager.cpp.
Referenced by init().
|
static |
Schedules a function to be called after when frames and then repeatedly after each subsequent period frames
Definition at line 15 of file CallbackManager.cpp.
Referenced by setTimeout().