summaryrefslogtreecommitdiff
path: root/common/elapi/elapi_async.h
blob: 24cb7f8bc4991a1cfa3aa9ee657c1426f4e26dee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
    ELAPI

    Header file for the ELAPI async processing interface.

    Copyright (C) Dmitri Pal <dpal@redhat.com> 2009

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef ELAPI_ASYNC_H
#define ELAPI_ASYNC_H

#include <sys/time.h>

/* Signature ELAPI callback function that
 * should be called when the event loop got an event on the
 * socket or file descriptor.
 * ELAPI will always try to write to sockets in async way
 * if the sink has this capability.
 * So this is the callback that will always be
 * invoked when we get ACK from the process receiving events.
 */
typedef int (*elapi_fd_callback)(int fd,                /* File descriptor     */
                                 void *elapi_data);     /* ELAPI supplied data */

/* Signature ELAPI callback function that
 * should be called when the event loop got a timer driven event.
 */
typedef int (*elapi_timer_callback)(void *elapi_data);  /* ELAPI supplied data */

/* Signature of the supplied by caller function that ELAPI
 * will call to add the fd into the application event processing loop.
 */
typedef int (*elapi_add_fd)(int fd,                     /* File descriptor to add */
                            void *callers_data,         /* Data that the function
                                                         * would need to do its work */
                            elapi_fd_callback handle,   /* Callback to call when event happens */
                            void *elapi_data);          /* Data to pass to the callback */

/* Signature of the supplied by caller function that ELAPI
 * will call to remove the fd from the application event processing loop.
 * The implementation of the function should assume that
 * ELAPI will close file/socket descriptor after colling this function.
 */
typedef int (*elapi_rem_fd)(int fd,                     /* File descriptor to add */
                            void *callers_data);        /* Data that the function
                                                         * would need to do its work */

/* Signature of the supplied by caller function that ELAPI
 * will call to add a new timer event to the application event processing loop.
 */
typedef int (*elapi_add_timer)(struct timeval timer,        /* Timer */
                               void *callers_data,          /* Data that the function
                                                             * would need to do its work */
                               elapi_timer_callback handle, /* Callback to call when event happens */
                               void *elapi_data);           /* Data to pass to the callback */





#endif