summaryrefslogtreecommitdiff
path: root/src/PollEventPoll.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2014-09-13 15:36:27 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2014-09-13 17:33:22 +0900
commit596e5c616218c9681adf4eb45077608510e2876e (patch)
treebe2c7fb20b14f0c4dc533c82dbb5dad23529d693 /src/PollEventPoll.h
parentf55c16c7edeb319a82217a91a87a35cddfd606b0 (diff)
Refactor event poll classes so that we don't have to allocate memory on query
I left Port and libuv classes, since I don't have them compiled. So they were updated minimally.
Diffstat (limited to 'src/PollEventPoll.h')
-rw-r--r--src/PollEventPoll.h15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/PollEventPoll.h b/src/PollEventPoll.h
index 0b88baef..bd754712 100644
--- a/src/PollEventPoll.h
+++ b/src/PollEventPoll.h
@@ -39,7 +39,7 @@
# include <poll.h>
-#include <set>
+#include <map>
#include "Event.h"
#include "a2functional.h"
@@ -64,19 +64,20 @@ private:
public:
KSocketEntry(sock_t socket);
+ KSocketEntry(const KSocketEntry&) = delete;
+ KSocketEntry(KSocketEntry&&) = default;
+
struct pollfd getEvents();
};
friend int accumulateEvent(int events, const KEvent& event);
private:
- typedef std::set<std::shared_ptr<KSocketEntry>,
- DerefLess<std::shared_ptr<KSocketEntry> > > KSocketEntrySet;
+ typedef std::map<sock_t, KSocketEntry> KSocketEntrySet;
KSocketEntrySet socketEntries_;
#ifdef ENABLE_ASYNC_DNS
- typedef std::set<std::shared_ptr<KAsyncNameResolverEntry>,
- DerefLess<std::shared_ptr<KAsyncNameResolverEntry> > >
- KAsyncNameResolverEntrySet;
+ typedef std::map<std::pair<AsyncNameResolver*, Command*>,
+ KAsyncNameResolverEntry> KAsyncNameResolverEntrySet;
KAsyncNameResolverEntrySet nameResolverEntries_;
#endif // ENABLE_ASYNC_DNS
@@ -86,7 +87,7 @@ private:
// The number of valid struct pollfd in pollfds_.
int pollfdNum_;
- struct pollfd* pollfds_;
+ std::unique_ptr<struct pollfd[]> pollfds_;
bool addEvents(sock_t socket, const KEvent& event);