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

Unified Diff: runtime/bin/eventhandler_linux.h

Issue 9332003: Use epoll for the event handler on Linux. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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 | « no previous file | runtime/bin/eventhandler_linux.cc » ('j') | runtime/bin/eventhandler_linux.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler_linux.h
diff --git a/runtime/bin/eventhandler_linux.h b/runtime/bin/eventhandler_linux.h
index b210e774ca8681500f51bc8d72d675dc88e21bcc..4812be152b4762053ef5e517abdaa2f07cd64993 100644
--- a/runtime/bin/eventhandler_linux.h
+++ b/runtime/bin/eventhandler_linux.h
@@ -30,17 +30,13 @@ enum PortDataFlags {
class SocketData {
public:
- explicit SocketData(intptr_t fd) : fd_(fd), port_(0), mask_(0), flags_(0) {
+ explicit SocketData(intptr_t fd)
+ : tracked_by_epoll_(false), fd_(fd), port_(0), mask_(0), flags_(0) {
ASSERT(fd_ != -1);
}
intptr_t GetPollEvents();
- void Unregister() {
- port_ = 0;
- mask_ = 0;
- }
-
void ShutdownRead() {
shutdown(fd_, SHUT_RD);
MarkClosedRead();
@@ -52,7 +48,8 @@ class SocketData {
}
void Close() {
- Unregister();
+ port_ = 0;
+ mask_ = 0;
flags_ = 0;
close(fd_);
fd_ = -1;
@@ -66,8 +63,6 @@ class SocketData {
void MarkClosedRead() { flags_ |= (1 << kClosedRead); }
void MarkClosedWrite() { flags_ |= (1 << kClosedWrite); }
- bool HasPollEvents() { return mask_ != 0; }
-
void SetPortAndMask(Dart_Port port, intptr_t mask) {
ASSERT(fd_ != -1);
port_ = port;
@@ -77,8 +72,11 @@ class SocketData {
intptr_t fd() { return fd_; }
Dart_Port port() { return port_; }
intptr_t mask() { return mask_; }
+ bool tracked_by_epoll() { return tracked_by_epoll_; }
+ void set_tracked_by_epoll(bool value) { tracked_by_epoll_ = value; }
private:
+ bool tracked_by_epoll_;
intptr_t fd_;
Dart_Port port_;
intptr_t mask_;
@@ -92,7 +90,7 @@ class EventHandlerImplementation {
~EventHandlerImplementation();
// Gets the socket data structure for a given file
- // descriptor. Creates a new one of one is not found.
+ // descriptor. Creates a new one if one is not found.
SocketData* GetSocketData(intptr_t fd);
void SendData(intptr_t id, Dart_Port dart_port, intptr_t data);
void StartEventHandler();
@@ -100,14 +98,13 @@ class EventHandlerImplementation {
private:
intptr_t GetTimeout();
bool GetInterruptMessage(InterruptMessage* msg);
- struct pollfd* GetPollFds(intptr_t* size);
- void HandleEvents(struct pollfd* pollfds, int pollfds_size, int result_size);
+ void HandleEvents(struct epoll_event* events, int size);
void HandleTimeout();
static void Poll(uword args);
void WakeupHandler(intptr_t id, Dart_Port dart_port, int64_t data);
void HandleInterruptFd();
void SetPort(intptr_t fd, Dart_Port dart_port, intptr_t mask);
- intptr_t GetPollEvents(struct pollfd* pollfd);
+ intptr_t GetPollEvents(intptr_t events, SocketData* sd);
static void* GetHashmapKeyFromFd(intptr_t fd);
static uint32_t GetHashmapHashFromFd(intptr_t fd);
@@ -115,6 +112,7 @@ class EventHandlerImplementation {
int64_t timeout_; // Time for next timeout.
Dart_Port timeout_port_;
int interrupt_fds_[2];
+ int epoll_fd;
Søren Gjesse 2012/02/07 07:54:12 Missing trailing underscore.
Mads Ager (google) 2012/02/07 08:09:35 Done.
};
« no previous file with comments | « no previous file | runtime/bin/eventhandler_linux.cc » ('j') | runtime/bin/eventhandler_linux.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698