![]() |
MySQL 26.7.0
Source Code Documentation
|
This template maintains the registry of tasks, with specific object types. More...
#include <task_registry.h>
Classes | |
| struct | Entry |
Public Types | |
| using | Task_object = Task_object_type |
| using | Task_object_ptr = std::unique_ptr< Task_object > |
| using | Mt_key = concurrency::Mutex_key |
| using | Mutex = concurrency::Mutex |
Public Member Functions | |
| Task_registry (Task_registry_psi psi_params={}) | |
| void | init (std::size_t capacity) |
| Task_registry (std::size_t capacity, Task_registry_psi psi_params={}) | |
| void | deinit () |
| ~Task_registry () | |
| template<typename T > | |
| bool | apply (Task_id_type id, T &&func) |
| Calls 'func' on a given task object. More... | |
| template<typename T > | |
| void | activate_and_apply (Task_id_type id, T &&func) |
| Unconditionally activates and calls 'func' on a given task object. More... | |
| bool | check_active (Task_id_type id) |
| template<typename T > | |
| void | apply_on_active (T &&func) |
| Calls 'func' on each registered task object. More... | |
| bool | register_entry (Task_id_type id, Task_object &&obj) |
| Function that registers a task, making it active. More... | |
| bool | activate_entry (Task_id_type id) |
| Function activates already registered entry. More... | |
| bool | activate_or_wait (Task_id_type id) |
| Function activates already registered entry, if entry is active it waits until its state changes to inactive. More... | |
| const Task_object & | get_ref (Task_id_type id) |
| Gets ref of internal object. More... | |
| Task_object & | get (Task_id_type id) |
| Unprotected access to task object. Firstly obtain the guard. More... | |
| auto | scoped_lock (Task_id_type id) |
| Task_object & | lock (Task_id_type id) |
| void | unlock (Task_id_type id) |
| bool | deactivate_entry (Task_id_type id) |
| Function that unregisters a task, making it inactive. More... | |
| template<typename Functor > | |
| bool | deactivate_entry (Task_id_type id, Functor &&func) |
| Function that unregisters a task, making it inactive, with functor. More... | |
| std::optional< Task_object > | get_and_deactivate_entry (Task_id_type id) |
| Function that unregisters a task, making it inactive, returns handled object if deactivation succeeded. More... | |
Static Public Attributes | |
| static constexpr std::size_t | cache_line_size |
| static constexpr std::size_t | default_capacity = 16384 |
Private Types | |
| using | Entry_ptr = std::unique_ptr< Entry > |
Private Member Functions | |
| void | init_tasks () |
| Entry_ptr & | get_entry (Task_id_type id) |
Private Attributes | |
| std::size_t | m_capacity {0} |
| std::vector< Entry_ptr, mysql::allocators::Allocator< Entry_ptr > > | m_tasks |
| bool | m_initialized {false} |
| Task_registry_psi | m_psi |
This template maintains the registry of tasks, with specific object types.
Those objects can be accessed simultaneously by different threads, as long as different threads access different task ids.
|
private |
| using mysql::scheduler::Task_registry< Task_id_type, Task_object_type >::Mt_key = concurrency::Mutex_key |
| using mysql::scheduler::Task_registry< Task_id_type, Task_object_type >::Mutex = concurrency::Mutex |
| using mysql::scheduler::Task_registry< Task_id_type, Task_object_type >::Task_object = Task_object_type |
| using mysql::scheduler::Task_registry< Task_id_type, Task_object_type >::Task_object_ptr = std::unique_ptr<Task_object> |
|
inline |
|
inline |
|
inline |
|
inline |
Unconditionally activates and calls 'func' on a given task object.
| id | Task id |
| func | function to be applied on a given registered task |
|
inline |
Function activates already registered entry.
|
inline |
Function activates already registered entry, if entry is active it waits until its state changes to inactive.
|
inline |
Calls 'func' on a given task object.
| id | Task id |
| func | function to be applied on a given registered task |
|
inline |
Calls 'func' on each registered task object.
Don't call when a new task can be activated, also, this is ineffective, but we don't expect to call this
| func | function to be applied on each, active task |
|
inline |
|
inline |
Function that unregisters a task, making it inactive.
|
inline |
Function that unregisters a task, making it inactive, with functor.
| id | Id of the task |
| func | Functor to call on the task object before deactivation, returns bool indicating whether to deactivate |
|
inline |
|
inline |
Unprotected access to task object. Firstly obtain the guard.
|
inline |
Function that unregisters a task, making it inactive, returns handled object if deactivation succeeded.
|
inlineprivate |
|
inline |
Gets ref of internal object.
| id | Task id |
|
inline |
|
inlineprivate |
|
inline |
|
inline |
Function that registers a task, making it active.
|
inline |
|
inline |
|
staticconstexpr |
|
staticconstexpr |
|
private |
|
private |
|
private |
|
private |