libtransistor
A userland library for the Nintendo Switch
|
Manager for waiting on synchronizable handles. More...
#include <libtransistor/types.h>
Go to the source code of this file.
Typedefs | |
typedef struct waiter_t | waiter_t |
typedef struct wait_record_t | wait_record_t |
Functions | |
waiter_t * | waiter_create () |
Creates a new waiter object. | |
wait_record_t * | waiter_add (waiter_t *waiter, handle_t handle, bool(*callback)(void *data, handle_t handle), void *data) |
Adds a handle to wait on to the waiter. More... | |
wait_record_t * | waiter_add_deadline (waiter_t *waiter, uint64_t deadline, uint64_t(*callback)(void *data), void *data) |
Adds a timed callback to the waiter. More... | |
wait_record_t * | waiter_add_signal (waiter_t *waiter, bool(*callback)(void *data), void *data) |
Adds a callback to the waiter that is signalled from another thread. More... | |
void | waiter_signal (waiter_t *waiter, wait_record_t *record) |
Marks the callback represented by this record to be called, and interrupts the waiter. More... | |
void | waiter_reset_signal (waiter_t *waiter, wait_record_t *record) |
Resets the signal marked by waiter_signal. More... | |
result_t | waiter_wait (waiter_t *waiter, uint64_t timeout) |
Waits for handles to signal. | |
void | waiter_cancel (waiter_t *waiter, wait_record_t *record) |
Removes a record from the waiter, interrupting it. More... | |
void | waiter_destroy (waiter_t *waiter) |
Destroys a waiter. More... | |
Manager for waiting on synchronizable handles.
wait_record_t* waiter_add | ( | waiter_t * | waiter, |
handle_t | handle, | ||
bool(*)(void *data, handle_t handle) | callback, | ||
void * | data | ||
) |
Adds a handle to wait on to the waiter.
waiter | Waiter to add callback to |
handle | Handle to wait on |
callback | Callback for when handle is signalled. Return true to keep the handle registered, false to unregister it. |
data | Userdata passed to callback |
wait_record_t* waiter_add_deadline | ( | waiter_t * | waiter, |
uint64_t | deadline, | ||
uint64_t(*)(void *data) | callback, | ||
void * | data | ||
) |
Adds a timed callback to the waiter.
waiter | Waiter to add callback to |
deadline | Target time to run callback, in system ticks. |
callback | Callback for when deadline is hit. Return zero to unregister, or return a positive value to set another deadline. |
data | Userdata passed to callback |
wait_record_t* waiter_add_signal | ( | waiter_t * | waiter, |
bool(*)(void *data) | callback, | ||
void * | data | ||
) |
Adds a callback to the waiter that is signalled from another thread.
waiter | Waiter to add callback to |
callback | Callback for when record is signalled. Return true to stay registered, or false to unregister. |
data | Userdata passed to callback |
Use waiter_signal from another thread, and call waiter_reset_signal from within the callback.
void waiter_cancel | ( | waiter_t * | waiter, |
wait_record_t * | record | ||
) |
Removes a record from the waiter, interrupting it.
This function may only be called once on any particular wait record.
void waiter_destroy | ( | waiter_t * | waiter | ) |
Destroys a waiter.
All wait records should be cancelled before calling this function.
void waiter_reset_signal | ( | waiter_t * | waiter, |
wait_record_t * | record | ||
) |
Resets the signal marked by waiter_signal.
record | Record to rest signal |
It is invalid to call this function on a record not returned from waiter_add_signal.
void waiter_signal | ( | waiter_t * | waiter, |
wait_record_t * | record | ||
) |
Marks the callback represented by this record to be called, and interrupts the waiter.
record | Record to signal |
It is invalid to call this function on a record not returned from waiter_add_signal.