|
Berserk
|
Scheduler is responsible for triggering the scheduled callbacks. More...
#include <Scheduler.hpp>
Public Types | |
| using | ScheduledFunc = std::function< void(float)> |
| using | PerformFunc = std::function< void()> |
| using | Handle = size_t |
Public Member Functions | |
| BRK_API Handle | Schedule (ScheduledFunc func, float interval, uint32 repeat=0, float delay=0.0f, bool paused=false) |
| Schedule function for execution on game thread. More... | |
| BRK_API Handle | ScheduleOnce (ScheduledFunc func, float delay, bool paused=false) |
| Schedule function for execution on game thread. More... | |
| BRK_API Handle | ScheduleUpdate (ScheduledFunc func, uint32 repeat=0, float delay=0.0f, bool paused=false) |
| Schedule function for execution on game thread. More... | |
| BRK_API void | ScheduleOnGameThread (PerformFunc func) |
| Schedule function to perform exactly on the game thread. More... | |
| BRK_API void | Cancel (Handle handle) |
| Unschedule function associated with specified handle. More... | |
| BRK_API void | Pause (Handle handle) |
| Pause scheduling of function associated with specified handle. More... | |
| BRK_API void | Resume (Handle handle) |
| Resume scheduling of function associated with specified handle. More... | |
Static Public Attributes | |
| static const uint32 | REPEAT_FOREVER = 0x7fffffff |
Friends | |
| class | Engine |
Scheduler is responsible for triggering the scheduled callbacks.
Use this class to:
Scheduler provides handlers for scheduler functions, so parameters and execution can be tweaked after scheduling.
| using Scheduler::Handle = size_t |
Handle to identify scheduled function entry
| using Scheduler::PerformFunc = std::function<void()> |
Function type to perform once on game thread
| using Scheduler::ScheduledFunc = std::function<void(float)> |
Function type to schedule
| void Scheduler::Cancel | ( | Scheduler::Handle | handle | ) |
Unschedule function associated with specified handle.
| handle | Handle of scheduled function |
| void Scheduler::Pause | ( | Scheduler::Handle | handle | ) |
Pause scheduling of function associated with specified handle.
| handle | Handle of scheduled function |
| void Scheduler::Resume | ( | Scheduler::Handle | handle | ) |
Resume scheduling of function associated with specified handle.
| handle | Handle of scheduled function |
| BRK_NS_BEGIN Scheduler::Handle Scheduler::Schedule | ( | Scheduler::ScheduledFunc | func, |
| float | interval, | ||
| uint32 | repeat = 0, |
||
| float | delay = 0.0f, |
||
| bool | paused = false |
||
| ) |
Schedule function for execution on game thread.
The scheduled function will be called every interval seconds. If paused is true, then it won't be called until it is resumed. Param repeat lets the action be executed repeat + 1 times in total. Param delay is how much to wait before scheduling first time.
REPEAT_FOREVER to schedule function to repeat forever.| func | Function to schedule |
| interval | Interval in seconds to schedule; must be greater that 0 |
| repeat | Repeats count to schedule; pass 0 to schedule exactly once |
| delay | Delay in seconds before first schedule |
| paused | Pass true if paused; not scheduled until paused is set to false |
| Scheduler::Handle Scheduler::ScheduleOnce | ( | Scheduler::ScheduledFunc | func, |
| float | delay, | ||
| bool | paused = false |
||
| ) |
Schedule function for execution on game thread.
The scheduled function will be called once. If paused is true, then it won't be called until it is resumed. Param delay is how much to wait before scheduling first time.
| func | Function to schedule |
| delay | Delay in seconds before first schedule |
| paused | Pass true if paused; not scheduled until paused is set to false |
| void Scheduler::ScheduleOnGameThread | ( | Scheduler::PerformFunc | func | ) |
Schedule function to perform exactly on the game thread.
Use this function to safely notify user by callback after async operation completions.
| func | Function to schedule |
| Scheduler::Handle Scheduler::ScheduleUpdate | ( | Scheduler::ScheduledFunc | func, |
| uint32 | repeat = 0, |
||
| float | delay = 0.0f, |
||
| bool | paused = false |
||
| ) |
Schedule function for execution on game thread.
The scheduled function will be called every frame. If paused is true, then it won't be called until it is resumed. Param repeat lets the action be executed repeat + 1 times in total. Param delay is how much to wait before scheduling first time.
REPEAT_FOREVER to schedule function to repeat forever.| func | Function to schedule |
| repeat | Repeats count to schedule; pass 0 to schedule exactly once |
| delay | Delay in seconds before first schedule |
| paused | Pass true if paused; not scheduled until paused is set to false |
|
friend |
|
static |
Auxiliary constant to say, that function must be scheduled forever