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

Side by Side Diff: lib/src/util/io.dart

Issue 1960503002: Fix all strong-mode errors and warnings. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: .analysis_options Created 4 years, 7 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
« no previous file with comments | « lib/src/util/forkable_stream.dart ('k') | lib/src/util/stream_queue.dart » ('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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:mirrors'; 8 import 'dart:mirrors';
9 9
10 import 'package:path/path.dart' as p; 10 import 'package:path/path.dart' as p;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 /// Repeatedly finds a probably-unused port on localhost and passes it to 157 /// Repeatedly finds a probably-unused port on localhost and passes it to
158 /// [tryPort] until it binds successfully. 158 /// [tryPort] until it binds successfully.
159 /// 159 ///
160 /// [tryPort] should return a non-`null` value or a Future completing to a 160 /// [tryPort] should return a non-`null` value or a Future completing to a
161 /// non-`null` value once it binds successfully. This value will be returned 161 /// non-`null` value once it binds successfully. This value will be returned
162 /// by [getUnusedPort] in turn. 162 /// by [getUnusedPort] in turn.
163 /// 163 ///
164 /// This is necessary for ensuring that our port binding isn't flaky for 164 /// This is necessary for ensuring that our port binding isn't flaky for
165 /// applications that don't print out the bound port. 165 /// applications that don't print out the bound port.
166 Future getUnusedPort(tryPort(int port)) { 166 Future/*<T>*/ getUnusedPort/*<T>*/(/*=T*/ tryPort(int port)) {
167 var value; 167 var/*=T*/ value;
168 return Future.doWhile(() async { 168 return Future.doWhile(() async {
169 value = await tryPort(await getUnsafeUnusedPort()); 169 value = await tryPort(await getUnsafeUnusedPort());
170 return value == null; 170 return value == null;
171 }).then((_) => value); 171 }).then((_) => value);
172 } 172 }
173 173
174 /// Returns a port that is probably, but not definitely, not in use. 174 /// Returns a port that is probably, but not definitely, not in use.
175 /// 175 ///
176 /// This has a built-in race condition: another process may bind this port at 176 /// This has a built-in race condition: another process may bind this port at
177 /// any time after this call has returned. If at all possible, callers should 177 /// any time after this call has returned. If at all possible, callers should
178 /// use [getUnusedPort] instead. 178 /// use [getUnusedPort] instead.
179 Future<int> getUnsafeUnusedPort() async { 179 Future<int> getUnsafeUnusedPort() async {
180 var socket = await RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0); 180 var socket = await RawServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0);
181 var port = socket.port; 181 var port = socket.port;
182 await socket.close(); 182 await socket.close();
183 return port; 183 return port;
184 } 184 }
OLDNEW
« no previous file with comments | « lib/src/util/forkable_stream.dart ('k') | lib/src/util/stream_queue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698