MXS-1915 Remove id from mxs::Worker

The id has now been moved from mxs::Worker to mxs::RoutingWorker
and the implications are felt in many places.

The primary need for the id was to be able to access worker specfic
data, maintained outside of a routing worker, when given a worker
(the id is used to index into an array). Slightly related to that
was the need to be able to iterate over all workers. That obviously
implies some kind of collection.

That causes all sorts of issues if there is a need for being able
to create and destroy a worker at runtime. With the id removed from
mxs::Worker all those issues are gone, and its perfectly ok to create
and destory mxs::Workers as needed.

Further, while there is a need to broadcast a particular message to
all _routing_ workers, it hardly makes sense to broadcast a particular
message too _all_ workers. Consequently, only routing workers are kept
in a collection and all static member functions dealing with all
workers (e.g. broadcast) have now been moved to mxs::RoutingWorker.

Now, instead of passing the id around we instead deal directly
with the worker pointer. Later the data in all those external arrays
will be moved into mxs::[Worker|RoutingWorker] so that worker related
data is maintained in exactly one place.
This commit is contained in:
Johan Wikman
2018-06-21 14:29:29 +03:00
parent 86b5238aaf
commit 8ea7d8898a
17 changed files with 719 additions and 879 deletions

View File

@ -109,7 +109,7 @@ extern int blr_write_special_event(ROUTER_INSTANCE *router,
extern int blr_file_new_binlog(ROUTER_INSTANCE *router, char *file);
static bool blr_handle_missing_files(ROUTER_INSTANCE *router,
char *new_file);
static void worker_cb_start_master(int worker_id, void* data);
static void worker_cb_start_master(MXS_WORKER*, void* data);
extern void blr_file_update_gtid(ROUTER_INSTANCE *router);
static int blr_check_connect_retry(ROUTER_INSTANCE *router);
@ -284,13 +284,13 @@ static void blr_start_master(void* data)
/**
* Callback start function to be called in the context of the main worker.
*
* @param worker_id The id of the worker in whose context the function is called.
* @param data The data to be passed to `blr_start_master`
* @param worker The worker in whose context the function is called.
* @param data The data to be passed to `blr_start_master`
*/
static void worker_cb_start_master(int worker_id, void* data)
static void worker_cb_start_master(MXS_WORKER* worker, void* data)
{
// This is itended to be called only in the main worker.
ss_dassert(worker_id == 0);
ss_dassert(worker == mxs_rworker_get(MXS_RWORKER_MAIN));
blr_start_master(data);
}
@ -325,10 +325,10 @@ bool blr_start_master_in_main(void* data)
* @param worker_id The id of the worker in whose context the function is called.
* @param data The data to be passed to `blr_start_master`
*/
static void worker_cb_close_master(int worker_id, void* data)
static void worker_cb_close_master(MXS_WORKER* worker, void* data)
{
// This is itended to be called only in the main worker.
ss_dassert(worker_id == 0);
ss_dassert(worker == mxs_rworker_get(MXS_RWORKER_MAIN));
blr_master_close(static_cast<ROUTER_INSTANCE*>(data));
}