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

Unified Diff: runtime/bin/eventhandler_fuchsia.h

Issue 2438903002: Fuchsia: Use mx_handle_wait_many in the eventhandler (Closed)
Patch Set: Add NULL checks Created 4 years, 2 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_fuchsia.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler_fuchsia.h
diff --git a/runtime/bin/eventhandler_fuchsia.h b/runtime/bin/eventhandler_fuchsia.h
index 013099232471828b81db8bac0a791805bc5f5cef..b168c6208be4d2f1cdebf02feaed9ca58c644931 100644
--- a/runtime/bin/eventhandler_fuchsia.h
+++ b/runtime/bin/eventhandler_fuchsia.h
@@ -9,11 +9,82 @@
#error Do not include eventhandler_fuchsia.h directly; use eventhandler.h instead.
#endif
+#include <errno.h>
#include <magenta/syscalls.h>
+#include "platform/signal_blocker.h"
+
namespace dart {
namespace bin {
+class DescriptorInfo : public DescriptorInfoBase {
+ public:
+ explicit DescriptorInfo(intptr_t fd) : DescriptorInfoBase(fd) { }
+
+ virtual ~DescriptorInfo() { }
+
+ virtual void Close() {
+ VOID_TEMP_FAILURE_RETRY(close(fd_));
+ fd_ = -1;
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DescriptorInfo);
+};
+
+class DescriptorInfoSingle
+ : public DescriptorInfoSingleMixin<DescriptorInfo> {
+ public:
+ explicit DescriptorInfoSingle(intptr_t fd)
+ : DescriptorInfoSingleMixin(fd, false) {}
+ virtual ~DescriptorInfoSingle() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DescriptorInfoSingle);
+};
+
+class DescriptorInfoMultiple
+ : public DescriptorInfoMultipleMixin<DescriptorInfo> {
+ public:
+ explicit DescriptorInfoMultiple(intptr_t fd)
+ : DescriptorInfoMultipleMixin(fd, false) {}
+ virtual ~DescriptorInfoMultiple() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DescriptorInfoMultiple);
+};
+
+// Information needed to call mx_handle_wait_many(), and to handle events.
+class MagentaWaitManyInfo {
+ public:
+ MagentaWaitManyInfo();
+ ~MagentaWaitManyInfo();
+
+ intptr_t capacity() const { return capacity_; }
+ intptr_t size() const { return size_; }
+ DescriptorInfo** descriptor_infos() const { return descriptor_infos_; }
+ mx_handle_t* handles() const { return handles_; }
+ mx_signals_t* signals() const { return signals_; }
+ mx_signals_state_t* signals_states() const { return signals_states_; }
+
+ void AddHandle(mx_handle_t handle, mx_signals_t signals, DescriptorInfo* di);
+ void RemoveHandle(mx_handle_t handle);
+
+ private:
+ static const intptr_t kInitialCapacity = 32;
+
+ void GrowArraysIfNeeded(intptr_t desired_size);
+
+ intptr_t capacity_;
+ intptr_t size_;
+ DescriptorInfo** descriptor_infos_;
+ mx_handle_t* handles_;
+ mx_signals_t* signals_;
+ mx_signals_state_t* signals_states_;
+
+ DISALLOW_COPY_AND_ASSIGN(MagentaWaitManyInfo);
+};
+
class EventHandlerImplementation {
public:
EventHandlerImplementation();
@@ -23,6 +94,8 @@ class EventHandlerImplementation {
void Start(EventHandler* handler);
void Shutdown();
+ const MagentaWaitManyInfo& info() const { return info_; }
+
private:
int64_t GetTimeout() const;
void HandleEvents();
@@ -35,6 +108,8 @@ class EventHandlerImplementation {
bool shutdown_;
mx_handle_t interrupt_handles_[2];
+ MagentaWaitManyInfo info_;
+
DISALLOW_COPY_AND_ASSIGN(EventHandlerImplementation);
};
« no previous file with comments | « no previous file | runtime/bin/eventhandler_fuchsia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698