|
| static hi_no_inline 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.
|
| |
◆ loop()
◆ add_socket()
Add a callback that reacts on a socket.
In most cases mode is set to one of the following values:
- error | read: Unblock when there is data available for read.
- error | write: Unblock when there is buffer space available for write.
- error | read | write: Unblock when there is data available for read of when there is buffer space available for write.
- Note
- Only one callback can be associated with a socket.
- Parameters
-
| fd | File descriptor of the socket. |
| mode | The mode of how select should work with the socket. |
| f | The callback to call when the file descriptor unblocks. |
◆ add_window()
Add a window to be redrawn from the event loop.
- Parameters
-
| window | A reference to an existing window, ready to be redrawn. |
◆ async_function()
| auto v1::loop::async_function |
( |
auto && | func | ) |
|
|
inlinenoexcept |
Call a function from the loop.
- Note
- It is safe to call this function from another thread.
- Parameters
-
| func | The function to call from the loop. The function must not take any argument, but may return a value. |
- Returns
- A
std::future for the return value.
◆ delay_function()
| timer_token_type v1::loop::delay_function |
( |
utc_nanoseconds | time_point, |
|
|
auto && | func ) |
|
inlinenoexcept |
Call a function at a certain time.
- Parameters
-
| time_point | The time at which to call the function. |
| func | The function to be called. |
◆ local()
| static hi_no_inline loop & v1::loop::local |
( |
| ) |
|
|
inlinestaticnoexcept |
Get or create the thread-local loop.
◆ main()
| static hi_no_inline loop & v1::loop::main |
( |
| ) |
|
|
inlinestaticnoexcept |
Get or create the main-loop.
- Note
- The first time main() is called must be from the main-thread. In this case there is no race condition on the first time main() is called.
◆ post_function()
| void v1::loop::post_function |
( |
auto && | func | ) |
|
|
inlinenoexcept |
Post a function to be called from the loop.
- Note
- It is safe to call this function from another thread.
- Parameters
-
| func | The function to call from the loop. The function must not take any arguments and return void. |
◆ remove_socket()
| void v1::loop::remove_socket |
( |
int | fd | ) |
|
|
inline |
Remove the callback associated with a socket.
- Parameters
-
| fd | The file descriptor of the socket. |
◆ repeat_function() [1/2]
Call a function repeatedly.
- Parameters
-
| period | The period between calls to the function. |
| func | The function to be called. |
◆ repeat_function() [2/2]
Call a function repeatedly.
- Parameters
-
| period | The period between calls to the function. |
| time_point | The time at which to call the function. |
| func | The function to be called. |
◆ resume()
| int v1::loop::resume |
( |
std::stop_token | stop_token = {} | ) |
|
|
inlinenoexcept |
Resume the loop on the current thread.
- Parameters
-
| 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. |
- Returns
- Exit code when the loop is exited.
◆ resume_once()
| void v1::loop::resume_once |
( |
bool | block = false | ) |
|
|
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.
- Note
- This function must be called from the same thread as
resume().
- Parameters
-
| block | Allow processing to block, this is normally done only inside resume(). |
◆ set_maximum_frame_rate()
| void v1::loop::set_maximum_frame_rate |
( |
double | frame_rate | ) |
|
|
inlinenoexcept |
Set maximum frame rate.
A frame rate above 30.0 may will cause the vsync thread to block on
- Parameters
-
| frame_rate | The maximum frame rate that a window will be updated. |
◆ timer()
| static hi_no_inline loop & v1::loop::timer |
( |
| ) |
|
|
inlinestaticnoexcept |
Get or create the timer event-loop.
- Note
- The first time this is called a thread is started to handle the timer events.
◆ wfree_post_function()
| void v1::loop::wfree_post_function |
( |
auto && | func | ) |
|
|
inlinenoexcept |
Wait-free post a function to be called from the loop.
- Note
- It is safe to call this function from another thread.
-
The event loop is not directly notified that a new function exists and will be delayed until after the loop has woken for other work.
-
The post is only wait-free if the function fifo is not full, and the function is small enough to fit in a slot on the fifo.
- Parameters
-
| func | The function to call from the loop. The function must not take any arguments and return void. |
The documentation for this class was generated from the following file: