MySQL 8.0.40
Source Code Documentation
|
The Scheduler queueing interface. More...
#include <mysql_scheduler.h>
Public Attributes | |
mysql_service_status_t(* | create )(mysql_scheduler_runnable_handle *out_handle, mysql_scheduler_runnable_function runnable, void *arg, const char *name, const char *comment, int interval_secs) |
Schedule a runnable task. More... | |
mysql_service_status_t(* | destroy )(mysql_scheduler_runnable_handle handle) |
End a scheduled task/subtask. More... | |
The Scheduler queueing interface.
This is a service that will allow registering a callback to be called every X seconds.
Each callback has a name. And a comment for the DBA to check.
A caller registers a callback together with its argument and gets a handle back. The callback will be put in rotation immediately and will be called after the defined interval. And it will keep being called until it's unregisterered using the handle.
Passing an argument is useful if you are to reuse the callback function to operate on many different states through registering it in multiple scheduled events. Having the argument passed down from the registering code to the callback saves the need of the callback to consult a global structure in a multi- thread safe fashion.
To use it one would do something like this:
mysql_service_status_t(* s_mysql_mysql_scheduler::create) (mysql_scheduler_runnable_handle *out_handle, mysql_scheduler_runnable_function runnable, void *arg, const char *name, const char *comment, int interval_secs) |
Schedule a runnable task.
[out] | out_handle | The context of the newly scheduled task. To be kept as an interaction vector with the running task. |
runnable | The function to call | |
arg | An argument to pass to the runnable. Must be valid until unregistered. | |
name | The name of the runnable in UTF8. | |
comment | A free form comment in UTF8. No more than 1024 bytes. | |
interval_secs | How frequently to schedule the task (in seconds). Must be greater than 1 since this is the resolution. |
false | success |
true | failure |
mysql_service_status_t(* s_mysql_mysql_scheduler::destroy) (mysql_scheduler_runnable_handle handle) |
End a scheduled task/subtask.
This will: unschedule the task wait for the scheduled task runnable to end, if running currently
handle | The context of the task to end |
false | success |
true | failure |