FreeRDP
pollset.h
1 
19 #ifndef WINPR_LIBWINPR_SYNCH_POLLSET_H_
20 #define WINPR_LIBWINPR_SYNCH_POLLSET_H_
21 
22 #include <winpr/wtypes.h>
23 #include <winpr/synch.h>
24 
25 #include <winpr/config.h>
26 
27 #ifndef _WIN32
28 
29 #ifdef WINPR_HAVE_POLL_H
30 #include <poll.h>
31 #else
32 #include <sys/select.h>
33 
34 typedef struct
35 {
36  int fd;
37  ULONG mode;
38 } FdIndex;
39 #endif
40 
42 {
43 #ifdef WINPR_HAVE_POLL_H
44  struct pollfd* pollset;
45  struct pollfd staticSet[MAXIMUM_WAIT_OBJECTS];
46  BOOL isStatic;
47 #else
48  FdIndex* fdIndex;
49  fd_set rset_base;
50  fd_set rset;
51  fd_set wset_base;
52  fd_set wset;
53  int nread, nwrite;
54  int maxFd;
55 #endif
56  size_t fillIndex;
57  size_t size;
58 };
59 
60 typedef struct winpr_poll_set WINPR_POLL_SET;
61 
62 BOOL pollset_init(WINPR_POLL_SET* set, size_t nhandles);
63 void pollset_uninit(WINPR_POLL_SET* set);
64 void pollset_reset(WINPR_POLL_SET* set);
65 BOOL pollset_add(WINPR_POLL_SET* set, int fd, ULONG mode);
66 int pollset_poll(WINPR_POLL_SET* set, DWORD dwMilliseconds);
67 
68 BOOL pollset_isSignaled(WINPR_POLL_SET* set, size_t idx);
69 BOOL pollset_isReadSignaled(WINPR_POLL_SET* set, size_t idx);
70 BOOL pollset_isWriteSignaled(WINPR_POLL_SET* set, size_t idx);
71 
72 #endif
73 
74 #endif /* WINPR_LIBWINPR_SYNCH_POLLSET_H_ */