Introduce private worker header

This commit is contained in:
Johan Wikman
2017-02-16 09:46:36 +02:00
parent bb6e0767cc
commit 72977128f7
4 changed files with 40 additions and 13 deletions

View File

@ -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.
*

View File

@ -68,7 +68,6 @@
#include <maxscale/utils.h>
#include <maxscale/version.h>
#include <maxscale/random_jkiss.h>
#include <maxscale/worker.h>
#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

View File

@ -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 <maxscale/worker.h>
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

View File

@ -11,7 +11,7 @@
* Public License.
*/
#include <maxscale/worker.h>
#include "maxscale/worker.h"
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
@ -20,24 +20,32 @@
#include <maxscale/config.h>
#include <maxscale/log_manager.h>
/**
* 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();