OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef BIN_EVENTHANDLER_WIN_H_ | 5 #ifndef BIN_EVENTHANDLER_WIN_H_ |
6 #define BIN_EVENTHANDLER_WIN_H_ | 6 #define BIN_EVENTHANDLER_WIN_H_ |
7 | 7 |
8 #if !defined(BIN_EVENTHANDLER_H_) | 8 #if !defined(BIN_EVENTHANDLER_H_) |
9 #error Do not include eventhandler_win.h directly; use eventhandler.h instead. | 9 #error Do not include eventhandler_win.h directly; use eventhandler.h instead. |
10 #endif | 10 #endif |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 HANDLE handle_; | 268 HANDLE handle_; |
269 HANDLE completion_port_; | 269 HANDLE completion_port_; |
270 EventHandlerImplementation* event_handler_; | 270 EventHandlerImplementation* event_handler_; |
271 | 271 |
272 OverlappedBuffer* data_ready_; // Buffer for data ready to be read. | 272 OverlappedBuffer* data_ready_; // Buffer for data ready to be read. |
273 OverlappedBuffer* pending_read_; // Buffer for pending read. | 273 OverlappedBuffer* pending_read_; // Buffer for pending read. |
274 OverlappedBuffer* pending_write_; // Buffer for pending write | 274 OverlappedBuffer* pending_write_; // Buffer for pending write |
275 | 275 |
276 DWORD last_error_; | 276 DWORD last_error_; |
277 | 277 |
| 278 ThreadId read_thread_id_; |
| 279 bool read_thread_running_; |
| 280 bool read_thread_finished_; |
| 281 Monitor* read_thread_monitor_; |
| 282 |
278 private: | 283 private: |
| 284 void WaitForReadThreadStarted(); |
| 285 void NotifyReadThreadStarted(); |
| 286 void WaitForReadThreadFinished(); |
| 287 void NotifyReadThreadFinished(); |
| 288 |
279 int flags_; | 289 int flags_; |
280 CRITICAL_SECTION cs_; // Critical section protecting this object. | 290 CRITICAL_SECTION cs_; // Critical section protecting this object. |
281 }; | 291 }; |
282 | 292 |
283 | 293 |
284 class FileHandle : public DescriptorInfoSingleMixin<Handle> { | 294 class FileHandle : public DescriptorInfoSingleMixin<Handle> { |
285 public: | 295 public: |
286 explicit FileHandle(HANDLE handle) | 296 explicit FileHandle(HANDLE handle) |
287 : DescriptorInfoSingleMixin(reinterpret_cast<intptr_t>(handle), true) { | 297 : DescriptorInfoSingleMixin(reinterpret_cast<intptr_t>(handle), true) { |
288 type_ = kFile; | 298 type_ = kFile; |
289 } | 299 } |
290 | 300 |
291 virtual void EnsureInitialized(EventHandlerImplementation* event_handler); | 301 virtual void EnsureInitialized(EventHandlerImplementation* event_handler); |
292 virtual bool IsClosed(); | 302 virtual bool IsClosed(); |
293 }; | 303 }; |
294 | 304 |
295 | 305 |
296 class StdHandle : public FileHandle { | 306 class StdHandle : public FileHandle { |
297 public: | 307 public: |
298 explicit StdHandle(HANDLE handle) | 308 explicit StdHandle(HANDLE handle) |
299 : FileHandle(handle), | 309 : FileHandle(handle), |
| 310 thread_id_(Thread::kInvalidThreadId), |
300 thread_wrote_(0), | 311 thread_wrote_(0), |
301 write_thread_exists_(false), | 312 write_thread_exists_(false), |
302 write_thread_running_(false), | 313 write_thread_running_(false), |
303 write_monitor_(new Monitor()) { | 314 write_monitor_(new Monitor()) { |
304 type_ = kStd; | 315 type_ = kStd; |
305 } | 316 } |
306 | 317 |
307 ~StdHandle() { | 318 ~StdHandle() { |
308 delete write_monitor_; | 319 delete write_monitor_; |
309 } | 320 } |
310 | 321 |
311 virtual void DoClose(); | 322 virtual void DoClose(); |
312 virtual intptr_t Write(const void* buffer, intptr_t num_bytes); | 323 virtual intptr_t Write(const void* buffer, intptr_t num_bytes); |
313 | 324 |
314 void WriteSyncCompleteAsync(); | 325 void WriteSyncCompleteAsync(); |
315 void RunWriteLoop(); | 326 void RunWriteLoop(); |
316 | 327 |
317 private: | 328 private: |
| 329 ThreadId thread_id_; |
318 intptr_t thread_wrote_; | 330 intptr_t thread_wrote_; |
319 bool write_thread_exists_; | 331 bool write_thread_exists_; |
320 bool write_thread_running_; | 332 bool write_thread_running_; |
321 Monitor* write_monitor_; | 333 Monitor* write_monitor_; |
322 }; | 334 }; |
323 | 335 |
324 | 336 |
325 class DirectoryWatchHandle : public DescriptorInfoSingleMixin<Handle> { | 337 class DirectoryWatchHandle : public DescriptorInfoSingleMixin<Handle> { |
326 public: | 338 public: |
327 DirectoryWatchHandle(HANDLE handle, int events, bool recursive) | 339 DirectoryWatchHandle(HANDLE handle, int events, bool recursive) |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 void HandleConnect(ClientSocket* client_socket, | 531 void HandleConnect(ClientSocket* client_socket, |
520 int bytes, | 532 int bytes, |
521 OverlappedBuffer* buffer); | 533 OverlappedBuffer* buffer); |
522 void HandleIOCompletion(DWORD bytes, ULONG_PTR key, OVERLAPPED* overlapped); | 534 void HandleIOCompletion(DWORD bytes, ULONG_PTR key, OVERLAPPED* overlapped); |
523 | 535 |
524 HANDLE completion_port() { return completion_port_; } | 536 HANDLE completion_port() { return completion_port_; } |
525 | 537 |
526 private: | 538 private: |
527 ClientSocket* client_sockets_head_; | 539 ClientSocket* client_sockets_head_; |
528 | 540 |
| 541 Monitor* startup_monitor_; |
| 542 ThreadId handler_thread_id_; |
| 543 |
529 TimeoutQueue timeout_queue_; // Time for next timeout. | 544 TimeoutQueue timeout_queue_; // Time for next timeout. |
530 bool shutdown_; | 545 bool shutdown_; |
531 HANDLE completion_port_; | 546 HANDLE completion_port_; |
532 }; | 547 }; |
533 | 548 |
534 } // namespace bin | 549 } // namespace bin |
535 } // namespace dart | 550 } // namespace dart |
536 | 551 |
537 #endif // BIN_EVENTHANDLER_WIN_H_ | 552 #endif // BIN_EVENTHANDLER_WIN_H_ |
OLD | NEW |