9 #ifndef __libutilxx__sella__net__SocketMux_H__
10 #define __libutilxx__sella__net__SocketMux_H__
12 #include "../../common.h"
14 #include "SocketException.h"
16 #include <sys/select.h>
17 #include <sys/epoll.h>
20 #include <forward_list>
28 #define EPOLL_MAXEVENTS_DEF 128
42 typedef std::shared_ptr<SocketMux> shared;
44 typedef std::map<int, Socket::shared> int_shared_map;
45 typedef std::forward_list<Socket::shared> shared_flist;
48 SocketMux(ssize_t epollMaxEvents = EPOLL_MAXEVENTS_DEF,
bool pthread_cancel =
true)
throw (SocketException);
51 int epoll(
struct timeval *tv = NULL)
throw (SocketException);
52 int epoll(uint64_t usec)
throw (SocketException);
54 int select(
struct timeval *tv = NULL)
throw (SocketException);
55 int select(uint64_t usec)
throw (SocketException);
56 int rselect(
struct timeval *tv = NULL)
throw (SocketException);
57 int rselect(uint64_t usec)
throw (SocketException);
58 int wselect(
struct timeval *tv = NULL)
throw (SocketException);
59 int wselect(uint64_t usec)
throw (SocketException);
60 int eselect(
struct timeval *tv = NULL)
throw (SocketException);
61 int eselect(uint64_t usec)
throw (SocketException);
62 int rwselect(
struct timeval *tv = NULL)
throw (SocketException);
63 int rwselect(uint64_t usec)
throw (SocketException);
65 void clear(
void)
throw (SocketException);
66 size_t size(
void)
const;
68 const shared_flist& getReadList(
void);
69 const shared_flist& getWriteList(
void);
70 const shared_flist& getExceptList(
void);
72 bool insertRead(Socket::shared socket)
throw (SocketException);
73 bool removeRead(Socket::shared socket)
throw (SocketException);
75 bool insertWrite(Socket::shared socket)
throw (SocketException);
76 bool removeWrite(Socket::shared socket)
throw (SocketException);
78 bool insertExcept(Socket::shared socket)
throw (SocketException);
79 bool removeExcept(Socket::shared socket)
throw (SocketException);
81 static const SocketMux::shared shared_ptr(ssize_t epollMaxEvents = EPOLL_MAXEVENTS_DEF,
bool pthread_cancel =
true)
throw (SocketException);
86 bool insert(Socket::shared socket, fd_set *set, int_shared_map *map, uint32_t events)
throw (SocketException);
87 bool remove(Socket::shared socket, fd_set *set, int_shared_map *map, uint32_t events)
throw (SocketException);
89 void clearLists(
void);
107 ssize_t epollMaxEvents;
108 struct epoll_event *events;