Files
MaxScale/include/maxscale/poll_core.h
Johan Wikman 8ea7d8898a 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.
2018-06-26 09:19:46 +03:00

57 lines
1.5 KiB
C

#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/bsl.
*
* Change Date: 2022-01-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.
*/
/**
* @file poll_basic.h The Descriptor Control Block
*/
#include <maxscale/cdefs.h>
#include <sys/epoll.h>
#include <maxscale/atomic.h>
MXS_BEGIN_DECLS
typedef enum mxs_poll_action
{
MXS_POLL_NOP = 0x00,
MXS_POLL_ACCEPT = 0x01,
MXS_POLL_READ = 0x02,
MXS_POLL_WRITE = 0x04,
MXS_POLL_HUP = 0x08,
MXS_POLL_ERROR = 0x10,
} mxs_poll_action_t;
struct mxs_poll_data;
/**
* Pointer to function that knows how to handle events for a particular
* 'struct mxs_poll_data' structure.
*
* @param data The `mxs_poll_data` instance that contained this function pointer.
* @param worker The worker.
* @param events The epoll events.
*
* @return A combination of mxs_poll_action_t enumeration values.
*/
// TODO: Change worker to mxs::Worker once this is C++-ified.
typedef uint32_t (*mxs_poll_handler_t)(struct mxs_poll_data* data, void* worker, uint32_t events);
typedef struct mxs_poll_data
{
mxs_poll_handler_t handler; /*< Handler for this particular kind of mxs_poll_data. */
void* owner; /*< Owning worker. */
} MXS_POLL_DATA;
MXS_END_DECLS