Lely core libraries 2.3.4
poll.hpp
Go to the documentation of this file.
1
22#ifndef LELY_IO_POLL_HPP_
23#define LELY_IO_POLL_HPP_
24
25#ifndef __cplusplus
26#error "include <lely/io/poll.h> for the C interface"
27#endif
28
29#include <lely/util/c_type.hpp>
30
31namespace lely {
32class IOPoll;
33}
36
37#include <lely/io/poll.h>
38
39namespace lely {
40
42template <>
44 typedef __io_poll value_type;
45 typedef value_type& reference;
46 typedef const value_type& const_reference;
47 typedef value_type* pointer;
48 typedef const value_type* const_pointer;
49
50 static void*
51 alloc() noexcept {
52 return __io_poll_alloc();
53 }
54 static void
55 free(void* ptr) noexcept {
56 __io_poll_free(ptr);
57 }
58
59 static pointer
60 init(pointer p) noexcept {
61 return __io_poll_init(p);
62 }
63 static void
64 fini(pointer p) noexcept {
65 __io_poll_fini(p);
66 }
67};
68
70class IOPoll : public incomplete_c_type<__io_poll> {
72
73 public:
74 IOPoll() : c_base() {}
75
76 int
77 watch(io_handle_t handle, struct io_event* event,
78 bool keep = false) noexcept {
79 return io_poll_watch(this, handle, event, keep);
80 }
81
82 int
83 wait(int maxevents, struct io_event* events, int timeout = 0) noexcept {
84 return io_poll_wait(this, maxevents, events, timeout);
85 }
86
87 int
88 signal(unsigned char sig) noexcept {
89 return io_poll_signal(this, sig);
90 }
91
92 protected:
93 ~IOPoll() {}
94};
95
96} // namespace lely
97
98#endif // !LELY_IO_POLL_HPP_
This header file is part of the utilities library; it contains the C to C++ interface declarations.
A CANopen value.
Definition val.hpp:42
An opaque I/O polling interface type.
Definition poll.hpp:70
The base class for a C++ interface to an incomplete C type.
Definition c_type.hpp:249
This header file is part of the I/O library; it contains I/O polling interface declarations.
int io_poll_signal(io_poll_t *poll, unsigned char sig)
Generates a signal event.
Definition poll.c:593
int io_poll_wait(io_poll_t *poll, int maxevents, struct io_event *events, int timeout)
Waits at most timeout milliseconds for at most maxevents I/O events to occur for any of the I/O devic...
Definition poll.c:352
lely::IOPoll io_poll_t
An opaque I/O polling interface type.
Definition poll.hpp:35
An I/O polling interface.
Definition poll.c:51
An I/O event.
Definition poll.h:50
An I/O device handle.
Definition handle.h:33
An object representing a file descriptor being monitored for I/O events.
Definition poll.h:56
A class template supplying a uniform interface to certain attributes of C types.
Definition c_type.hpp:350