HikoGUI
A low latency retained GUI
|
Public Member Functions | |
loop (loop const &)=delete | |
loop (loop &&) noexcept=delete | |
loop & | operator= (loop const &)=delete |
loop & | operator= (loop &&) noexcept=delete |
void | set_maximum_frame_rate (double frame_rate) noexcept |
Set maximum frame rate. | |
void | set_vsync_monitor_id (uintptr_t id) noexcept |
Set the monitor id for vertical sync. | |
template<forward_of< void()> Func> | |
void | wfree_post_function (Func &&func) noexcept |
Wait-free post a function to be called from the loop. | |
template<forward_of< void()> Func> | |
void | post_function (Func &&func) noexcept |
Post a function to be called from the loop. | |
template<typename Func > | |
auto | async_function (Func &&func) noexcept |
Call a function from the loop. | |
template<forward_of< void()> Func> | |
callback< void()> | delay_function (utc_nanoseconds time_point, Func &&func) noexcept |
Call a function at a certain time. | |
template<forward_of< void()> Func> | |
callback< void()> | repeat_function (std::chrono::nanoseconds period, utc_nanoseconds time_point, Func &&func) noexcept |
Call a function repeatedly. | |
template<forward_of< void()> Func> | |
callback< void()> | repeat_function (std::chrono::nanoseconds period, Func &&func) noexcept |
Call a function repeatedly. | |
void | subscribe_render (weak_callback< void(utc_nanoseconds)> callback) noexcept |
template<forward_of< void(utc_nanoseconds)> Func> | |
callback< void(utc_nanoseconds)> | subscribe_render (Func &&func) noexcept |
Subscribe a render function to be called on vsync. | |
void | add_socket (int fd, socket_event event_mask, std::function< void(int, socket_events const &)> f) |
Add a callback that reacts on a socket. | |
void | remove_socket (int fd) |
Remove the callback associated with a socket. | |
int | resume (std::stop_token stop_token={}) noexcept |
Resume the loop on the current thread. | |
void | resume_once (bool block=false) noexcept |
Resume for a single iteration. | |
bool | on_thread () const noexcept |
Check if the current thread is the same as the loop's thread. | |
Static Public Member Functions | |
static loop & | local () noexcept |
Get or create the thread-local loop. | |
static hi_no_inline loop & | main () noexcept |
Get or create the main-loop. | |
static hi_no_inline loop & | timer () noexcept |
Get or create the timer event-loop. | |
|
inline |
Add a callback that reacts on a socket.
In most cases mode is set to one of the following values:
fd | File descriptor of the socket. |
event_mask | The socket events to wait for. |
f | The callback to call when the file descriptor unblocks. |
|
inlinenoexcept |
Call a function from the loop.
func | The function to call from the loop. The function must not take any argument, but may return a value. |
std::future
for the return value.
|
inlinenoexcept |
Call a function at a certain time.
time_point | The time at which to call the function. |
func | The function to be called. |
|
inlinestaticnoexcept |
Get or create the thread-local loop.
|
inlinestaticnoexcept |
|
inlinenoexcept |
Check if the current thread is the same as the loop's thread.
The loop's thread is the thread that calls resume().
|
inlinenoexcept |
Post a function to be called from the loop.
func | The function to call from the loop. The function must not take any arguments and return void. |
|
inline |
Remove the callback associated with a socket.
fd | The file descriptor of the socket. |
|
inlinenoexcept |
Call a function repeatedly.
period | The period between calls to the function. |
func | The function to be called. |
|
inlinenoexcept |
Call a function repeatedly.
period | The period between calls to the function. |
time_point | The time at which to call the function. |
func | The function to be called. |
|
inlinenoexcept |
Resume the loop on the current thread.
stop_token | The thread's stop token to use to determine when to stop. If not stop token is given, then resume will automatically stop when there are no more windows, sockets, functions or timers. |
|
inlinenoexcept |
Resume for a single iteration.
The resume_once(false)
may be used to continue processing events and GUI redraws while the GUI event queue is blocked. This happens on win32 when a window is being moved, resized, the title bar or system menu being clicked.
It should be called often, as it will be used to process network messages and latency of network processing will be increased based on the amount of times this function is called.
resume()
. block | Allow processing to block, this is normally done only inside resume() . |
|
inlinenoexcept |
Set maximum frame rate.
A frame rate above 30.0 may will cause the vsync thread to block on
frame_rate | The maximum frame rate that a window will be updated. |
|
inlinenoexcept |
Set the monitor id for vertical sync.
|
inlinenoexcept |
Subscribe a render function to be called on vsync.
f | A function to be called when vsync occurs. |
|
inlinestaticnoexcept |
Get or create the timer event-loop.
|
inlinenoexcept |
Wait-free post a function to be called from the loop.
func | The function to call from the loop. The function must not take any arguments and return void. |