Files
sdk/runtime/bin/eventhandler_linux.h
T
dgrove@google.com 4c0f559d23 Initial checkin.
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@15 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-05 05:20:07 +00:00

58 lines
1.6 KiB
C++

// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef BIN_EVENTHANDLER_LINUX_H_
#define BIN_EVENTHANDLER_LINUX_H_
typedef struct {
intptr_t id;
Dart_Port dart_port;
int64_t data;
} InterruptMessage;
typedef struct {
Dart_Port dart_port;
intptr_t mask;
} PortData;
class EventHandlerImplementation {
public:
EventHandlerImplementation();
~EventHandlerImplementation();
void SendData(intptr_t id, Dart_Port dart_port, intptr_t data);
void StartEventHandler();
private:
intptr_t GetTimeout();
bool GetInterruptMessage(InterruptMessage* msg);
struct pollfd* GetPollFds(intptr_t* size);
void RegisterFdWakeup(intptr_t id, Dart_Port dart_port, intptr_t data);
void UnregisterFdWakeup(intptr_t id);
void CloseFd(intptr_t id);
void UnregisterFd(intptr_t id);
void HandleEvents(struct pollfd* pollfds, int pollfds_size, int result_size);
void HandleTimeout();
static void* Poll(void* 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);
Dart_Port PortFor(intptr_t fd);
intptr_t GetPollEvents(struct pollfd* pollfd);
void SetPollEvents(struct pollfd* pollfds, intptr_t mask);
PortData* port_map_;
intptr_t port_map_entries_;
intptr_t port_map_size_;
int64_t timeout_; // Time for next timeout.
Dart_Port timeout_port_;
int interrupt_fds_[2];
};
#endif // BIN_EVENTHANDLER_LINUX_H_