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

Side by Side Diff: runtime/bin/eventhandler_win.cc

Issue 471743002: - Make sure that the threads for dart::bin are in the correct namespace. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/eventhandler_win.h ('k') | runtime/bin/lockers.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "bin/eventhandler.h" 8 #include "bin/eventhandler.h"
9 9
10 #include <winsock2.h> // NOLINT 10 #include <winsock2.h> // NOLINT
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // Completing asynchronously. 285 // Completing asynchronously.
286 pending_read_ = buffer; 286 pending_read_ = buffer;
287 return true; 287 return true;
288 } 288 }
289 OverlappedBuffer::DisposeBuffer(buffer); 289 OverlappedBuffer::DisposeBuffer(buffer);
290 HandleIssueError(); 290 HandleIssueError();
291 return false; 291 return false;
292 } else { 292 } else {
293 // Completing asynchronously through thread. 293 // Completing asynchronously through thread.
294 pending_read_ = buffer; 294 pending_read_ = buffer;
295 int result = dart::Thread::Start(ReadFileThread, 295 int result = Thread::Start(ReadFileThread,
296 reinterpret_cast<uword>(this)); 296 reinterpret_cast<uword>(this));
297 if (result != 0) { 297 if (result != 0) {
298 FATAL1("Failed to start read file thread %d", result); 298 FATAL1("Failed to start read file thread %d", result);
299 } 299 }
300 return true; 300 return true;
301 } 301 }
302 } 302 }
303 303
304 304
305 bool Handle::IssueRecvFrom() { 305 bool Handle::IssueRecvFrom() {
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 // not available as a RawSocket, but only wrapped in a Socket. 740 // not available as a RawSocket, but only wrapped in a Socket.
741 // Note that we return '0', unless a thread have already completed a write. 741 // Note that we return '0', unless a thread have already completed a write.
742 MonitorLocker locker(write_monitor_); 742 MonitorLocker locker(write_monitor_);
743 if (thread_wrote_ > 0) { 743 if (thread_wrote_ > 0) {
744 if (num_bytes > thread_wrote_) num_bytes = thread_wrote_; 744 if (num_bytes > thread_wrote_) num_bytes = thread_wrote_;
745 thread_wrote_ -= num_bytes; 745 thread_wrote_ -= num_bytes;
746 return num_bytes; 746 return num_bytes;
747 } 747 }
748 if (!write_thread_exists_) { 748 if (!write_thread_exists_) {
749 write_thread_exists_ = true; 749 write_thread_exists_ = true;
750 int result = dart::Thread::Start(WriteFileThread, 750 int result = Thread::Start(WriteFileThread,
751 reinterpret_cast<uword>(this)); 751 reinterpret_cast<uword>(this));
752 if (result != 0) { 752 if (result != 0) {
753 FATAL1("Failed to start write file thread %d", result); 753 FATAL1("Failed to start write file thread %d", result);
754 } 754 }
755 while (!write_thread_running_) { 755 while (!write_thread_running_) {
756 // Wait until we the thread is running. 756 // Wait until we the thread is running.
757 locker.Wait(Monitor::kNoTimeout); 757 locker.Wait(Monitor::kNoTimeout);
758 } 758 }
759 } 759 }
760 // Only queue up to INT_MAX bytes. 760 // Only queue up to INT_MAX bytes.
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 delete msg; 1344 delete msg;
1345 } else { 1345 } else {
1346 handler_impl->HandleIOCompletion(bytes, key, overlapped); 1346 handler_impl->HandleIOCompletion(bytes, key, overlapped);
1347 } 1347 }
1348 } 1348 }
1349 delete handler; 1349 delete handler;
1350 } 1350 }
1351 1351
1352 1352
1353 void EventHandlerImplementation::Start(EventHandler* handler) { 1353 void EventHandlerImplementation::Start(EventHandler* handler) {
1354 int result = dart::Thread::Start(EventHandlerEntry, 1354 int result = Thread::Start(EventHandlerEntry,
1355 reinterpret_cast<uword>(handler)); 1355 reinterpret_cast<uword>(handler));
1356 if (result != 0) { 1356 if (result != 0) {
1357 FATAL1("Failed to start event handler thread %d", result); 1357 FATAL1("Failed to start event handler thread %d", result);
1358 } 1358 }
1359 1359
1360 // Initialize Winsock32 1360 // Initialize Winsock32
1361 if (!Socket::Initialize()) { 1361 if (!Socket::Initialize()) {
1362 FATAL("Failed to initialized Windows sockets"); 1362 FATAL("Failed to initialized Windows sockets");
1363 } 1363 }
1364 } 1364 }
1365 1365
1366 1366
1367 void EventHandlerImplementation::Shutdown() { 1367 void EventHandlerImplementation::Shutdown() {
1368 SendData(kShutdownId, 0, 0); 1368 SendData(kShutdownId, 0, 0);
1369 } 1369 }
1370 1370
1371 } // namespace bin 1371 } // namespace bin
1372 } // namespace dart 1372 } // namespace dart
1373 1373
1374 #endif // defined(TARGET_OS_WINDOWS) 1374 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « runtime/bin/eventhandler_win.h ('k') | runtime/bin/lockers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698