1 /* 2 3 Copyright (c) 2016 Martin Sustrik 4 5 Permission is hereby granted, free of charge, to any person obtaining a copy 6 of this software and associated documentation files (the "Software"), 7 to deal in the Software without restriction, including without limitation 8 the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 and/or sell copies of the Software, and to permit persons to whom 10 the Software is furnished to do so, subject to the following conditions: 11 12 The above copyright notice and this permission notice shall be included 13 in all copies or substantial portions of the Software. 14 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 IN THE SOFTWARE. 22 23 */ 24 25 #ifndef DILL_POLLSET_INCLUDED 26 #define DILL_POLLSET_INCLUDED 27 28 /* User overloads. */ 29 #if defined DILL_EPOLL 30 #include "epoll.h.inc" 31 #elif defined DILL_KQUEUE 32 #include "kqueue.h.inc" 33 #elif defined DILL_POLL 34 #include "poll.h.inc" 35 /* Defaults. */ 36 #elif defined HAVE_EPOLL 37 #include "epoll.h.inc" 38 #elif defined HAVE_KQUEUE 39 #include "kqueue.h.inc" 40 #else 41 #include "poll.h.inc" 42 #endif 43 44 int dill_ctx_pollset_init(struct dill_ctx_pollset *ctx); 45 void dill_ctx_pollset_term(struct dill_ctx_pollset *ctx); 46 47 /* Add waiting for an in event on the fd to the list of current clauses. */ 48 int dill_pollset_in(struct dill_fdclause *fdcl, int id, int fd); 49 50 /* Add waiting for an out event on the fd to the list of current clauses. */ 51 int dill_pollset_out(struct dill_fdclause *fdcl, int id, int fd); 52 53 /* Drop any cached info about the file descriptor. */ 54 int dill_pollset_clean(int fd); 55 56 /* Wait for events. 'timeout' is in milliseconds. Return 0 if the timeout expired or 57 1 if at least one clause was triggered. */ 58 int dill_pollset_poll(int timeout); 59 60 #endif 61 62