summaryrefslogtreecommitdiff
path: root/cli/bench/http.rs
diff options
context:
space:
mode:
authorbokuweb <bokuweb12@gmail.com>2022-06-29 17:16:02 +0900
committerGitHub <noreply@github.com>2022-06-29 13:46:02 +0530
commit91570ba6e85ae927f0979c0d2dde5684cb6823ff (patch)
tree3c9c58dd5062a713aa85a11a2b894cab311b1b19 /cli/bench/http.rs
parent76d387fb93c741a5def8d120892be65e35164a01 (diff)
chore(cli): remove unnecessary unsafe in bench (#15000)
Diffstat (limited to 'cli/bench/http.rs')
-rw-r--r--cli/bench/http.rs17
1 files changed, 5 insertions, 12 deletions
diff --git a/cli/bench/http.rs b/cli/bench/http.rs
index 3646f472c..3735fde1b 100644
--- a/cli/bench/http.rs
+++ b/cli/bench/http.rs
@@ -1,9 +1,9 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
use super::Result;
+use std::sync::atomic::{AtomicU16, Ordering};
use std::{collections::HashMap, path::Path, process::Command, time::Duration};
pub use test_util::{parse_wrk_output, WrkOutput as HttpBenchmarkResult};
-
// Some of the benchmarks in this file have been renamed. In case the history
// somehow gets messed up:
// "node_http" was once called "node"
@@ -150,18 +150,11 @@ fn run(
Ok(parse_wrk_output(&output))
}
+static NEXT_PORT: AtomicU16 = AtomicU16::new(4544);
fn get_port() -> u16 {
- static mut NEXT_PORT: u16 = 4544;
-
- // TODO(bartlomieju):
- #[allow(clippy::undocumented_unsafe_blocks)]
- let port = unsafe {
- let p = NEXT_PORT;
- NEXT_PORT += 1;
- p
- };
-
- port
+ let p = NEXT_PORT.load(Ordering::SeqCst);
+ NEXT_PORT.store(p.wrapping_add(1), Ordering::SeqCst);
+ p
}
fn server_addr(port: u16) -> String {