Add shutdown support

The shutdown is now performed so that a shutdown message is
sent to all workers. When the workers receive that message, they
turn on a shutdown flag, which subsequently is checked in the poll
loop.
This commit is contained in:
Johan Wikman
2017-02-16 13:54:18 +02:00
parent ab37333ce5
commit 5138032fe5
7 changed files with 99 additions and 31 deletions

View File

@ -59,4 +59,38 @@ bool mxs_worker_start(MXS_WORKER* worker);
*/
void mxs_worker_join(MXS_WORKER* worker);
/**
* Initate shutdown of worker.
*
* @param worker The worker that should be shutdown.
*
* @attention A call to this function will only initiate the shutdowm,
* the worker will not have shut down when the function returns.
*
* @attention This function is signal safe.
*/
void mxs_worker_shutdown(MXS_WORKER* worker);
/**
* Initate shutdown of all workers.
*
* @attention A call to this function will only initiate the shutdowm,
* the workers will not have shut down when the function returns.
*
* @attention This function is signal safe.
*/
void mxs_worker_shutdown_workers();
/**
* Query whether worker should shutdown.
*
* @param worker The worker in question.
*
* @return True, if the worker should shut down, false otherwise.
*/
static inline bool mxs_worker_should_shutdown(MXS_WORKER* worker)
{
return worker->should_shutdown;
}
MXS_END_DECLS