2 * Copyright 2016 IoT.bzh
3 * Author: José Bollo <jose.bollo@iot.bzh>
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 struct afb_pollmgr_itf
22 int (*wait)(int timeout, void *pollclosure);
23 void *(*open)(int fd, void *closure, void *pollclosure);
24 int (*on_readable)(void *hndl, void (*cb)(void *closure));
25 int (*on_writable)(void *hndl, void (*cb)(void *closure));
26 void (*on_hangup)(void *hndl, void (*cb)(void *closure));
27 void (*close)(void *hndl);
32 const struct afb_pollmgr_itf *itf;
36 static inline int afb_pollmgr_wait(struct afb_pollmgr pollmgr, int timeout)
38 return pollmgr.itf->wait(timeout, pollmgr.closure);
41 static inline void *afb_pollmgr_open(struct afb_pollmgr pollmgr, int fd, void *closure)
43 return pollmgr.itf->open(fd, closure, pollmgr.closure);
46 static inline int afb_pollmgr_on_readable(struct afb_pollmgr pollmgr, void *hndl, void (*cb)(void *closure))
48 return pollmgr.itf->on_readable(hndl, cb);
51 static inline int afb_pollmgr_on_writable(struct afb_pollmgr pollmgr, void *hndl, void (*cb)(void *closure))
53 return pollmgr.itf->on_writable(hndl, cb);
56 static inline void afb_pollmgr_on_hangup(struct afb_pollmgr pollmgr, void *hndl, void (*cb)(void *closure))
58 pollmgr.itf->on_hangup(hndl, cb);