diff --git a/include/maxscale/worker.h b/include/maxscale/worker.h index 11070479f..102db5466 100644 --- a/include/maxscale/worker.h +++ b/include/maxscale/worker.h @@ -37,14 +37,6 @@ enum mxs_worker_msg_id MXS_WORKER_MSG_PING }; -/** - * Initialize the worker mechanism. - * - * To be called once at process startup. This will cause as many workers - * to be created as the number of threads defined. - */ -void mxs_worker_init(); - /** * Return the worker associated with the provided worker id. * diff --git a/server/core/gateway.cc b/server/core/gateway.cc index 1b04f1dc0..220238093 100644 --- a/server/core/gateway.cc +++ b/server/core/gateway.cc @@ -68,7 +68,6 @@ #include #include #include -#include #include "maxscale/config.h" #include "maxscale/dcb.h" @@ -78,6 +77,7 @@ #include "maxscale/poll.h" #include "maxscale/service.h" #include "maxscale/statistics.h" +#include "maxscale/worker.h" #define STRING_BUFFER_SIZE 1024 #define PIDFD_CLOSED -1 diff --git a/server/core/maxscale/worker.h b/server/core/maxscale/worker.h new file mode 100644 index 000000000..9d4be34f3 --- /dev/null +++ b/server/core/maxscale/worker.h @@ -0,0 +1,27 @@ +#pragma once +/* + * Copyright (c) 2016 MariaDB Corporation Ab + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file and at www.mariadb.com/bsl11. + * + * Change Date: 2019-07-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2 or later of the General + * Public License. + */ + +#include + +MXS_BEGIN_DECLS + +/** + * Initialize the worker mechanism. + * + * To be called once at process startup. This will cause as many workers + * to be created as the number of threads defined. + */ +void mxs_worker_init(); + +MXS_END_DECLS diff --git a/server/core/worker.c b/server/core/worker.c index 8e5668f7c..48fff9126 100644 --- a/server/core/worker.c +++ b/server/core/worker.c @@ -11,7 +11,7 @@ * Public License. */ -#include +#include "maxscale/worker.h" #include #include #include @@ -20,24 +20,32 @@ #include #include +/** + * Unit variables. + */ static struct worker_unit { int n_workers; MXS_WORKER** workers; } this_unit; +/** + * Structure used for sending cross-thread messages. + */ typedef struct worker_message { - int id; - int64_t arg1; - void* arg2; + int id; /*< Message id. */ + int64_t arg1; /*< Message specific first argument. */ + void* arg2; /*< Message specific second argument. */ } WORKER_MESSAGE; + static MXS_WORKER* worker_create(int worker_id); static void worker_free(MXS_WORKER* worker); static void worker_message_handler(MXS_WORKER* worker, int msg_id, int64_t arg1, void* arg2); static uint32_t worker_poll_handler(MXS_POLL_DATA *data, int worker_id, uint32_t events); + void mxs_worker_init() { this_unit.n_workers = config_threadcount();