| Index: dart/runtime/bin/eventhandler_macos.h
|
| diff --git a/dart/runtime/bin/eventhandler_macos.h b/dart/runtime/bin/eventhandler_macos.h
|
| index 4e32dc0656f159b44e50d34b16240d075a38b116..dbb563bbfb525515872629f9607e2cd1374bc3ff 100644
|
| --- a/dart/runtime/bin/eventhandler_macos.h
|
| +++ b/dart/runtime/bin/eventhandler_macos.h
|
| @@ -21,62 +21,49 @@
|
| namespace dart {
|
| namespace bin {
|
|
|
| -class InterruptMessage {
|
| +class DescriptorInfoMacOS : public DescriptorInfo {
|
| public:
|
| - intptr_t id;
|
| - Dart_Port dart_port;
|
| - int64_t data;
|
| -};
|
| -
|
| -
|
| -class SocketData {
|
| - public:
|
| - explicit SocketData(intptr_t fd)
|
| - : fd_(fd),
|
| - port_(0),
|
| - mask_(0),
|
| - tracked_by_kqueue_(false),
|
| - tokens_(16) {
|
| - ASSERT(fd_ != -1);
|
| - }
|
| + explicit DescriptorInfoMacOS(intptr_t fd)
|
| + : DescriptorInfo(fd), tracked_by_kqueue_(false) { }
|
|
|
| - bool HasReadEvent();
|
| - bool HasWriteEvent();
|
| + virtual ~DescriptorInfoMacOS() { }
|
|
|
| - bool IsListeningSocket() { return (mask_ & (1 << kListeningSocket)) != 0; }
|
| + intptr_t GetPollEvents();
|
|
|
| - void SetPortAndMask(Dart_Port port, intptr_t mask) {
|
| - ASSERT(fd_ != -1);
|
| - port_ = port;
|
| - mask_ = mask;
|
| + virtual void Close() {
|
| + VOID_TEMP_FAILURE_RETRY(close(fd_));
|
| + fd_ = -1;
|
| }
|
|
|
| - intptr_t fd() { return fd_; }
|
| - Dart_Port port() { return port_; }
|
| - intptr_t mask() { return mask_; }
|
| - bool tracked_by_kqueue() { return tracked_by_kqueue_; }
|
| void set_tracked_by_kqueue(bool value) {
|
| tracked_by_kqueue_ = value;
|
| }
|
|
|
| - // Returns true if the last token was taken.
|
| - bool TakeToken() {
|
| - tokens_--;
|
| - return tokens_ == 0;
|
| - }
|
| + bool tracked_by_kqueue() { return tracked_by_kqueue_; }
|
|
|
| - // Returns true if the tokens was 0 before adding.
|
| - bool ReturnToken() {
|
| - tokens_++;
|
| - return tokens_ == 1;
|
| - }
|
| + bool HasReadEvent();
|
|
|
| - private:
|
| - intptr_t fd_;
|
| - Dart_Port port_;
|
| - intptr_t mask_;
|
| + bool HasWriteEvent();
|
| +
|
| + protected:
|
| bool tracked_by_kqueue_;
|
| - int tokens_;
|
| +};
|
| +
|
| +
|
| +class DescriptorInfoSingleMacOS
|
| + : public DescriptorInfoSingle<DescriptorInfoMacOS> {
|
| + public:
|
| + explicit DescriptorInfoSingleMacOS(intptr_t fd) : DescriptorInfoSingle(fd) { }
|
| + virtual ~DescriptorInfoSingleMacOS() { }
|
| +};
|
| +
|
| +
|
| +class DescriptorInfoMultipleMacOS
|
| + : public DescriptorInfoMultiple<DescriptorInfoMacOS> {
|
| + public:
|
| + explicit DescriptorInfoMultipleMacOS(intptr_t fd)
|
| + : DescriptorInfoMultiple(fd) {}
|
| + virtual ~DescriptorInfoMultipleMacOS() {}
|
| };
|
|
|
|
|
| @@ -87,7 +74,7 @@ class EventHandlerImplementation {
|
|
|
| // Gets the socket data structure for a given file
|
| // descriptor. Creates a new one if one is not found.
|
| - SocketData* GetSocketData(intptr_t fd);
|
| + DescriptorInfoMacOS* GetDescriptorInfoMacOS(intptr_t fd);
|
| void SendData(intptr_t id, Dart_Port dart_port, int64_t data);
|
| void Start(EventHandler* handler);
|
| void Shutdown();
|
| @@ -100,7 +87,7 @@ class EventHandlerImplementation {
|
| 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 GetEvents(struct kevent* event, SocketData* sd);
|
| + intptr_t GetEvents(struct kevent* event, DescriptorInfoMacOS* si);
|
| static void* GetHashmapKeyFromFd(intptr_t fd);
|
| static uint32_t GetHashmapHashFromFd(intptr_t fd);
|
|
|
|
|