2
* @file geis_backend_multiplexor.h
3
* @brief internal GEIS backend multiplexor interface
5
* Copyright 2010 Canonical Ltd.
7
* This library is free software; you can redistribute it and/or modify it under
8
* the terms of the GNU Lesser General Public License as published by the Free
9
* Software Foundation; either version 3 of the License, or (at your option) any
12
* This library is distributed in the hope that it will be useful, but WITHOUT
13
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
17
* You should have received a copy of the GNU Lesser General Public License
18
* along with this program; if not, write to the Free Software Foundation, Inc.,
19
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#ifndef GEIS_BACKEND_MULTIPLEXOR_H_
22
#define GEIS_BACKEND_MULTIPLEXOR_H_
24
#include "geis/geis.h"
28
* Multiplexes back end events into a single notification file descriptor.
30
* The GEIS API presents a single file descriptor to the application to watch
31
* for activity notification. A back end may be monitoring activity on more
32
* than one file descriptor. The multiplexor combines these requirements.
34
typedef struct _GeisBackendMultiplexor *GeisBackendMultiplexor;
37
* Indicates the type of fd event that occurred on a multiplexed descriptor.
39
typedef enum _GeisBackendMultiplexorEvent
41
GEIS_BE_MX_READ_AVAILABLE,
42
GEIS_BE_MX_WRITE_AVAILABLE
43
} GeisBackendMultiplexorEvent;
46
* Handles events occurring on multiplexed file descriptors.
48
* Back ends must provide a callback with this signature to the multiplexor.
50
typedef void (*GeisBackendFdEventCallback)(int fd,
51
GeisBackendMultiplexorEvent event,
55
* Constructs a new back end multiplexor.
57
GeisBackendMultiplexor geis_backend_multiplexor_new();
60
* A reasonable default value for the max_events_per_pump parameter to
61
* geis_backend_multiplexor_new().
63
#define GEIS_BE_MX_DEFAULT_EVENTS_PER_PUMP 16
66
* Destroys a back end multiplexor.
68
* @param[in] mx The back end multiplexor to destroy.
70
void geis_backend_multiplexor_delete(GeisBackendMultiplexor mx);
73
* Adds a file descriptor to a back end multiplexor.
75
* @param[in] mx The back end multiplexor.
76
* @param[in] fd The file descriptor to add.
78
void geis_backend_multiplexor_add_fd(GeisBackendMultiplexor mx,
80
GeisBackendFdEventCallback callback,
84
* Removes a file descriptor from a back end multiplexor.
86
* @param[in] mx The back end multiplexor.
87
* @param[in] fd The file descriptor to remove.
89
void geis_backend_multiplexor_remove_fd(GeisBackendMultiplexor mx,
93
* Gets the file descriptor of the back end multiplexor.
95
* @param[in] mx The back end multiplexor.
97
int geis_backend_multiplexor_fd(GeisBackendMultiplexor mx);
100
* Gets the maximum number of fd events per pump.
102
* @param[in] mx The back end multiplexor.
104
int geis_backend_multiplexor_max_events_per_pump(GeisBackendMultiplexor mx);
107
* Sets the maximum fd events per pump of the multiplexor.
109
* @param[in] mx The back end multiplexor.
110
* @param[in] max_events_per_pump The maximum number of fd events pumped
111
* per call of geis_backend_multiplexor_pump().
113
* This value is tunable to accommodate different back ends and
114
* application/toolkit requirements.
116
void geis_backend_multiplexor_set_max_events_per_pump(GeisBackendMultiplexor mx,
117
int max_events_per_pump);
120
* Exercises the back end multiplexor.
122
* @param[in] mx The back end multiplexor.
124
* Dispatches any events on multiplexed file descriptors to their assciated
127
GeisStatus geis_backend_multiplexor_pump(GeisBackendMultiplexor mx);
129
#endif /* GEIS_BACKEND_MULTIPLEXOR_H_ */