nngn
Loading...
Searching...
No Matches
nngn::Schedule Class Reference

Executor of deferred and recurrent tasks. More...

#include <schedule.h>

Collaboration diagram for nngn::Schedule:

Classes

struct  BaseEntry
 
struct  Entry
 
struct  TimeEntry
 

Public Types

enum  Flag : u8 { NONE , IGNORE_FAILURES = 1u << 0 , HEARTBEAT = 1u << 1 }
 
using Fn = bool(*)(void*)
 Signature for task functions.
 

Public Member Functions

void init (const Timing *t)
 
std::size_t n (void) const
 
std::size_t n_atexit (void) const
 
std::size_t next (Entry e)
 
std::size_t frame (u64 f, Entry e)
 
std::size_t in (std::chrono::milliseconds t, Entry e)
 
std::size_t at (Timing::time_point t, Entry e)
 
std::size_t atexit (Entry e)
 
bool cancel (std::size_t i)
 
bool cancel_atexit (std::size_t i)
 
bool update (void)
 
bool exit (void)
 

Private Member Functions

template<typename T >
std::size_t add (std::vector< T > *v, T t)
 
template<typename T >
bool cancel_common (std::vector< T > *v, std::size_t i)
 

Private Attributes

std::vector< TimeEntryv = {}
 
std::vector< BaseEntryatexit_v = {}
 
u32 cur_gen = 0
 
const Timingtiming = nullptr
 

Detailed Description

Executor of deferred and recurrent tasks.

Tasks can be scheduled on a given frame (next, frame), at a given time (in, at), or a combination of those (execution happens at the first occurrence of either). A separate category exists for tasks that should be executed when the application terminates (atexit).

Member Typedef Documentation

◆ Fn

using nngn::Schedule::Fn = bool(*)(void*)

Signature for task functions.

The single parameter is a pointer to the data associated with the task on construction. true should be returned on success.

Member Enumeration Documentation

◆ Flag

Enumerator
NONE 
IGNORE_FAILURES 

Whether a failure in the task is critical or can be tolerated.

HEARTBEAT 

After it is triggered, execute again at every frame.

Member Function Documentation

◆ add()

template<typename T >
std::size_t nngn::Schedule::add ( std::vector< T > * v,
T t )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ at()

std::size_t nngn::Schedule::at ( Timing::time_point t,
Entry e )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ atexit()

std::size_t nngn::Schedule::atexit ( Entry e)
Here is the call graph for this function:

◆ cancel()

bool nngn::Schedule::cancel ( std::size_t i)
Here is the call graph for this function:

◆ cancel_atexit()

bool nngn::Schedule::cancel_atexit ( std::size_t i)
Here is the call graph for this function:

◆ cancel_common()

template<typename T >
bool nngn::Schedule::cancel_common ( std::vector< T > * v,
std::size_t i )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ exit()

bool nngn::Schedule::exit ( void )
Here is the call graph for this function:

◆ frame()

std::size_t nngn::Schedule::frame ( u64 f,
Entry e )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ in()

std::size_t nngn::Schedule::in ( std::chrono::milliseconds t,
Entry e )
Here is the call graph for this function:

◆ init()

void nngn::Schedule::init ( const Timing * t)
inline
Here is the caller graph for this function:

◆ n()

std::size_t nngn::Schedule::n ( void ) const
inline

◆ n_atexit()

std::size_t nngn::Schedule::n_atexit ( void ) const
inline

◆ next()

std::size_t nngn::Schedule::next ( Entry e)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update()

bool nngn::Schedule::update ( void )
Here is the call graph for this function:

Member Data Documentation

◆ atexit_v

std::vector<BaseEntry> nngn::Schedule::atexit_v = {}
private

◆ cur_gen

u32 nngn::Schedule::cur_gen = 0
private

◆ timing

const Timing* nngn::Schedule::timing = nullptr
private

◆ v

std::vector<TimeEntry> nngn::Schedule::v = {}
private

The documentation for this class was generated from the following files: