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

Unified Diff: runtime/bin/eventhandler_win.h

Issue 25631005: Reuse thread when writing stdout/stderr on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make the thread a part of the StdHandle. Created 7 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_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler_win.h
diff --git a/runtime/bin/eventhandler_win.h b/runtime/bin/eventhandler_win.h
index 945277b78dcb4436f65a6094c4148cd1a4825cb8..43562cd1d0f95aac8e82666c20f8701f72156f40 100644
--- a/runtime/bin/eventhandler_win.h
+++ b/runtime/bin/eventhandler_win.h
@@ -13,6 +13,7 @@
#include <mswsock.h>
#include "bin/builtin.h"
+#include "platform/thread.h"
namespace dart {
@@ -132,6 +133,7 @@ class Handle {
public:
enum Type {
kFile,
+ kStd,
kDirectoryWatch,
kClientSocket,
kListenSocket
@@ -156,7 +158,7 @@ class Handle {
// Socket interface exposing normal socket operations.
int Available();
int Read(void* buffer, int num_bytes);
- int Write(const void* buffer, int num_bytes);
+ virtual int Write(const void* buffer, int num_bytes);
// Internal interface used by the event handler.
virtual bool IssueRead();
@@ -211,7 +213,6 @@ class Handle {
}
void ReadSyncCompleteAsync();
- void WriteSyncCompleteAsync();
DWORD last_error() { return last_error_; }
void set_last_error(DWORD last_error) { last_error_ = last_error; }
@@ -242,7 +243,6 @@ class Handle {
OverlappedBuffer* pending_write_; // Buffer for pending write
DWORD last_error_;
- DWORD thread_wrote_;
private:
int flags_;
@@ -259,7 +259,35 @@ class FileHandle : public Handle {
virtual void EnsureInitialized(EventHandlerImplementation* event_handler);
virtual bool IsClosed();
+};
+
+
+class StdHandle : public FileHandle {
+ public:
+ explicit StdHandle(HANDLE handle)
+ : FileHandle(handle),
+ thread_wrote_(0),
+ write_thread_exists_(false),
+ write_thread_running_(false),
+ write_monitor_(new Monitor()) {
+ type_ = kStd;
+ }
+
+ ~StdHandle() {
+ delete write_monitor_;
+ }
+
virtual void DoClose();
+ virtual int Write(const void* buffer, int num_bytes);
+
+ void WriteSyncCompleteAsync();
+ void RunWriteLoop();
+
+ private:
+ DWORD thread_wrote_;
+ bool write_thread_exists_;
+ bool write_thread_running_;
+ dart::Monitor* write_monitor_;
};
« no previous file with comments | « no previous file | runtime/bin/eventhandler_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698