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

Side by Side Diff: runtime/bin/vmservice/vmservice_io.dart

Issue 584023004: Service isolate rework (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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/vmservice/server.dart ('k') | runtime/bin/vmservice_dartium.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 library vmservice_io; 5 library vmservice_io;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:isolate'; 10 import 'dart:isolate';
11 import 'dart:vmservice'; 11 import 'dart:vmservice';
12 12
13 part 'loader.dart';
13 part 'resources.dart'; 14 part 'resources.dart';
14 part 'server.dart'; 15 part 'server.dart';
15 16
16 // The TCP ip/port that the HTTP server listens on. 17 // The TCP ip/port that the HTTP server listens on.
17 int _port; 18 int _port;
18 String _ip; 19 String _ip;
19 // Should the HTTP server auto start? 20 // Should the HTTP server auto start?
20 bool _autoStart; 21 bool _autoStart;
21 22
22 bool _isWindows = false; 23 bool _isWindows = false;
23 24
25 var _signalWatch;
26
24 // HTTP servr. 27 // HTTP servr.
25 Server server; 28 Server server;
26 Future<Server> serverFuture; 29 Future<Server> serverFuture;
27 30
28 void _bootServer() { 31 void _bootServer() {
29 // Load resources. 32 // Load resources.
30 _triggerResourceLoad(); 33 _triggerResourceLoad();
31 // Lazily create service. 34 // Lazily create service.
32 var service = new VMService(); 35 var service = new VMService();
33 // Lazily create server. 36 // Lazily create server.
(...skipping 13 matching lines...) Expand all
47 _bootServer(); 50 _bootServer();
48 } 51 }
49 // Toggle HTTP server. 52 // Toggle HTTP server.
50 if (server.running) { 53 if (server.running) {
51 serverFuture = server.shutdown(true).then(_clearFuture); 54 serverFuture = server.shutdown(true).then(_clearFuture);
52 } else { 55 } else {
53 serverFuture = server.startup().then(_clearFuture); 56 serverFuture = server.startup().then(_clearFuture);
54 } 57 }
55 } 58 }
56 59
57 void _registerSignalHandler(Stream signalWatch(ProcessSignal signal)) { 60 void _registerSignalHandler() {
58 if (_isWindows) { 61 if (_isWindows) {
59 // Cannot register for signals on Windows. 62 // Cannot register for signals on Windows.
60 return; 63 return;
61 } 64 }
62 signalWatch(ProcessSignal.SIGQUIT).listen(_onSignal); 65 _signalWatch(ProcessSignal.SIGQUIT).listen(_onSignal);
63 } 66 }
64 67
65 main(Stream signalWatch(ProcessSignal signal)) { 68 const _shortDelay = const Duration(milliseconds: 10);
69
70 main() {
66 if (_autoStart) { 71 if (_autoStart) {
67 _bootServer(); 72 _bootServer();
68 server.startup(); 73 server.startup();
74 // It's just here to push an event on the event loop so that we invoke the
75 // scheduled microtasks.
76 Timer.run(() {});
69 } 77 }
70 _registerSignalHandler(signalWatch); 78 scriptLoadPort.handler = _processLoadRequest;
79 // Register signal handler after a small delay to avoid stalling main
80 // isolate startup.
81 new Timer(_shortDelay, _registerSignalHandler);
82 return scriptLoadPort;
71 } 83 }
OLDNEW
« no previous file with comments | « runtime/bin/vmservice/server.dart ('k') | runtime/bin/vmservice_dartium.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698