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

Side by Side Diff: pkg/analysis_server/lib/stdio_server.dart

Issue 235953019: Exit stdio-based analysis server when stdin closed. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 stdio.server; 5 library stdio.server;
6 6
7 import 'dart:async';
7 import 'dart:io'; 8 import 'dart:io';
8 9
9 import 'package:analysis_server/src/channel.dart'; 10 import 'package:analysis_server/src/channel.dart';
10 import 'package:analysis_server/src/socket_server.dart'; 11 import 'package:analysis_server/src/socket_server.dart';
11 12
12 /** 13 /**
13 * Instances of the class [StdioServer] implement a simple server operating 14 * Instances of the class [StdioServer] implement a simple server operating
14 * over standard input and output. The primary responsibility of this server 15 * over standard input and output. The primary responsibility of this server
15 * is to split incoming messages on newlines and pass them along to the 16 * is to split incoming messages on newlines and pass them along to the
16 * analysis server. 17 * analysis server.
17 */ 18 */
18 class StdioAnalysisServer { 19 class StdioAnalysisServer {
19 /** 20 /**
20 * An object that can handle either a WebSocket connection or a connection 21 * An object that can handle either a WebSocket connection or a connection
21 * to the client over stdio. 22 * to the client over stdio.
22 */ 23 */
23 SocketServer socketServer; 24 SocketServer socketServer;
24 25
25 /** 26 /**
26 * Initialize a newly created stdio server. 27 * Initialize a newly created stdio server.
27 */ 28 */
28 StdioAnalysisServer(this.socketServer); 29 StdioAnalysisServer(this.socketServer);
29 30
30 /** 31 /**
31 * Begin serving requests over stdio. 32 * Begin serving requests over stdio.
33 *
34 * Return a future that will be completed when stdin closes.
32 */ 35 */
33 void serveStdio() { 36 Future serveStdio() {
34 socketServer.createAnalysisServer(new ByteStreamServerChannel(stdin, stdout) 37 ByteStreamServerChannel serverChannel = new ByteStreamServerChannel(stdin,
35 ); 38 stdout);
39 socketServer.createAnalysisServer(serverChannel);
40 return serverChannel.closed;
36 } 41 }
37 } 42 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698