Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(967)

Unified Diff: runtime/bin/eventhandler_macos.h

Issue 9186035: Use hash map for event handler file descriptor map (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r3482 Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/eventhandler_linux.cc ('k') | runtime/bin/eventhandler_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler_macos.h
diff --git a/runtime/bin/eventhandler_macos.h b/runtime/bin/eventhandler_macos.h
index 902aa5e0dc6e097039bd159d82b87cf9c8dabe07..014f27febfc00e3fce3cc060e60f1a7c443f061e 100644
--- a/runtime/bin/eventhandler_macos.h
+++ b/runtime/bin/eventhandler_macos.h
@@ -12,6 +12,7 @@
#include <unistd.h>
#include <sys/socket.h>
+#include "bin/hashmap.h"
class InterruptMessage {
public:
@@ -29,6 +30,10 @@ enum PortDataFlags {
class SocketData {
public:
+ explicit SocketData(intptr_t fd) : fd_(fd), port_(0), mask_(0), flags_(0) {
+ ASSERT(fd_ != -1);
+ }
+
intptr_t GetPollEvents();
void Unregister() {
@@ -50,7 +55,7 @@ class SocketData {
Unregister();
flags_ = 0;
close(fd_);
- fd_ = 0;
+ fd_ = -1;
}
bool IsListeningSocket() { return (mask_ & (1 << kListeningSocket)) != 0; }
@@ -64,12 +69,12 @@ class SocketData {
bool HasPollEvents() { return mask_ != 0; }
void SetPortAndMask(Dart_Port port, intptr_t mask) {
+ ASSERT(fd_ != -1);
port_ = port;
mask_ = mask;
}
intptr_t fd() { return fd_; }
- void set_fd(intptr_t fd) { fd_ = fd; }
Dart_Port port() { return port_; }
intptr_t mask() { return mask_; }
@@ -86,6 +91,8 @@ class EventHandlerImplementation {
EventHandlerImplementation();
~EventHandlerImplementation();
+ // Gets the socket data structure for a given file
+ // descriptor. Creates a new one of one is not found.
SocketData* GetSocketData(intptr_t fd);
void SendData(intptr_t id, Dart_Port dart_port, intptr_t data);
void StartEventHandler();
@@ -101,9 +108,10 @@ class EventHandlerImplementation {
void HandleInterruptFd();
void SetPort(intptr_t fd, Dart_Port dart_port, intptr_t mask);
intptr_t GetPollEvents(struct pollfd* pollfd);
+ static void* GetHashmapKeyFromFd(intptr_t fd);
+ static uint32_t GetHashmapHashFromFd(intptr_t fd);
- SocketData* socket_map_;
- intptr_t socket_map_size_;
+ HashMap socket_map_;
int64_t timeout_; // Time for next timeout.
Dart_Port timeout_port_;
int interrupt_fds_[2];
« no previous file with comments | « runtime/bin/eventhandler_linux.cc ('k') | runtime/bin/eventhandler_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698