File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change 1
1
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
2
2
3
3
use super :: Result ;
4
+ use std:: sync:: atomic:: { AtomicU16 , Ordering } ;
4
5
use std:: { collections:: HashMap , path:: Path , process:: Command , time:: Duration } ;
5
6
pub use test_util:: { parse_wrk_output, WrkOutput as HttpBenchmarkResult } ;
6
-
7
7
// Some of the benchmarks in this file have been renamed. In case the history
8
8
// somehow gets messed up:
9
9
// "node_http" was once called "node"
@@ -150,18 +150,11 @@ fn run(
150
150
Ok ( parse_wrk_output ( & output) )
151
151
}
152
152
153
+ static NEXT_PORT : AtomicU16 = AtomicU16 :: new ( 4544 ) ;
153
154
fn get_port ( ) -> u16 {
154
- static mut NEXT_PORT : u16 = 4544 ;
155
-
156
- // TODO(bartlomieju):
157
- #[ allow( clippy:: undocumented_unsafe_blocks) ]
158
- let port = unsafe {
159
- let p = NEXT_PORT ;
160
- NEXT_PORT += 1 ;
161
- p
162
- } ;
163
-
164
- port
155
+ let p = NEXT_PORT . load ( Ordering :: SeqCst ) ;
156
+ NEXT_PORT . store ( p. wrapping_add ( 1 ) , Ordering :: SeqCst ) ;
157
+ p
165
158
}
166
159
167
160
fn server_addr ( port : u16 ) -> String {
You can’t perform that action at this time.
0 commit comments