s4:torture/rpc: avoid compiler warnings
[Samba.git] / source3 / lib / poll_funcs / poll_funcs.h
blob6072eb5b035990054aba605b1d1a6ec321a76e5b
1 /*
2 * Unix SMB/CIFS implementation.
3 * Copyright (C) Volker Lendecke 2013
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 /**
20 * @file poll_funcs.h
22 * @brief event loop abstraction
26 * This is inspired by AvahiWatch, the avahi event loop abstraction.
29 #ifndef __POLL_FUNCS_H__
30 #define __POLL_FUNCS_H__
32 #include "replace.h"
34 /**
35 * poll_watch and poll_timeout are undefined here, every implementation can
36 * implement its own structures.
39 struct poll_watch;
40 struct poll_timeout;
42 struct poll_funcs {
44 /**
45 * @brief Create a new file descriptor watch
47 * @param[in] funcs The callback array
48 * @param[in] fd The fd to watch
49 * @param[in] events POLLIN and POLLOUT or'ed together
50 * @param[in] callback Function to call by the implementation
51 * @param[in] private_data Pointer to give back to callback
53 * @return A new poll_watch struct
56 struct poll_watch *(*watch_new)(
57 const struct poll_funcs *funcs, int fd, short events,
58 void (*callback)(struct poll_watch *w, int fd,
59 short events, void *private_data),
60 void *private_data);
62 /**
63 * @brief Change the watched events for a struct poll_watch
65 * @param[in] w The poll_watch to change
66 * @param[in] events new POLLIN and POLLOUT or'ed together
69 void (*watch_update)(struct poll_watch *w, short events);
71 /**
72 * @brief Read events currently watched
74 * @param[in] w The poll_watch to inspect
76 * @returns The events currently watched
79 short (*watch_get_events)(struct poll_watch *w);
81 /**
82 * @brief Free a struct poll_watch
84 * @param[in] w The poll_watch struct to free
87 void (*watch_free)(struct poll_watch *w);
90 /**
91 * @brief Create a new timeout watch
93 * @param[in] funcs The callback array
94 * @param[in] tv The time when the timeout should trigger
95 * @param[in] callback Function to call at time "ts"
96 * @param[in] private_data Pointer to give back to callback
98 * @return A new poll_timeout struct
101 struct poll_timeout *(*timeout_new)(
102 const struct poll_funcs *funcs, const struct timeval *tv,
103 void (*callback)(struct poll_timeout *t, void *private_data),
104 void *private_data);
107 * @brief Change the timeout of a watch
109 * @param[in] t The timeout watch to change
110 * @param[in] ts The new trigger time
113 void (*timeout_update)(struct poll_timeout *t,
114 const struct timespec *ts);
117 * @brief Free a poll_timeout
119 * @param[in] t The poll_timeout to free
122 void (*timeout_free)(struct poll_timeout *t);
125 * @brief private data for use by the implementation
128 void *private_data;
131 #endif