|
CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
|
APIs for an example thread pool. More...
#include <__cheri_sealed.h>#include <cdefs.h>#include <stdlib.h>#include <token.h>#include <type_traits>#include <cheri.hh>Go to the source code of this file.
Classes | |
| struct | ThreadPoolMessage |
| Message to a thread pool. More... | |
Namespaces | |
| namespace | thread_pool |
| For C++ programmers, we provide some more user-friendly wrappers. | |
| namespace | thread_pool::detail |
| Implementation details, should not be used outside of this header. | |
Typedefs | |
| typedef __cheri_callback void(* | ThreadPoolCallback) (CHERI_SEALED(void *)) |
| The type of a thread-pool callback. | |
Functions | |
| int | thread_pool_async (ThreadPoolCallback fn, CHERI_SEALED(void *) data) |
| Invoke a function that takes a void* argument in another thread. | |
| int | thread_pool_run (void) |
| Run a thread pool. | |
| template<typename T> | |
| TokenKey | thread_pool::detail::sealing_key_for_type () |
| Helper that generates a different sealing key per type using the allocator's token mechanism. | |
| template<typename T> | |
| __cheri_callback void | thread_pool::detail::wrap_callback_lambda (CHERI_SEALED(void *) rawFn) |
| Helper that provides a callback function for invoking and then freeing a sealed heap-allocated lambda. | |
| template<typename Fn> | |
| __cheri_callback void | thread_pool::detail::wrap_callback_function (CHERI_SEALED(void *)) |
| Helper to wrap pure C function (including a stateless lambda) as a callback. | |
| template<typename T> | |
| int | thread_pool::async (T &&lambda) |
| Asynchronously invoke a lambda. | |
APIs for an example thread pool.
This does not provide any availability guarantees (work dispatched to it can block a thread indefinitely) so this should be used with care.
The thread pool exposed by this header is implemented in the thread_pool compartment, which must be linked to the final firmware image.
Definition in file thread_pool.h.
| typedef __cheri_callback void(* ThreadPoolCallback) (CHERI_SEALED(void *)) |
The type of a thread-pool callback.
This is a CHERI callback so that it can run in the compartment that schedule the work to run, but a different thread.
Definition at line 24 of file thread_pool.h.
| int thread_pool_async | ( | ThreadPoolCallback | fn, |
| CHERI_SEALED(void *) | data ) |
Invoke a function that takes a void* argument in another thread.
The function will be invoked with data as the argument. The data argument must be sealed.
This can block indefinitely until the thread pool is able to process a message.
FIXME: We should add a non-blocking variant of this.
Returns 0 on success, -EINVAL if either of the arguments are invalid.
References thread_pool_async().
Referenced by thread_pool::async(), and thread_pool_async().
| int thread_pool_run | ( | void | ) |
Run a thread pool.
This does not return, despite the claimed type, and can be used as a thread entry point.
References thread_pool_run().
Referenced by thread_pool_run().