Skip to content

Commit aaf8a6e

Browse files
committed
tcp-stress-test: Factor out thread count as constant.
1 parent 2ad98a0 commit aaf8a6e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/test/run-pass/tcp-stress.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ use std::sync::mpsc::channel;
2121
use std::time::Duration;
2222
use std::thread::{self, Builder};
2323

24+
const TARGET_CNT: usize = 1000;
25+
2426
fn main() {
2527
// This test has a chance to time out, try to not let it time out
2628
thread::spawn(move|| -> () {
@@ -42,8 +44,9 @@ fn main() {
4244
});
4345

4446
let (tx, rx) = channel();
47+
4548
let mut spawned_cnt = 0;
46-
for _ in 0..1000 {
49+
for _ in 0..TARGET_CNT {
4750
let tx = tx.clone();
4851
let res = Builder::new().stack_size(64 * 1024).spawn(move|| {
4952
match TcpStream::connect(addr) {
@@ -66,6 +69,6 @@ fn main() {
6669
for _ in 0..spawned_cnt {
6770
rx.recv().unwrap();
6871
}
69-
assert_eq!(spawned_cnt, 1000);
72+
assert_eq!(spawned_cnt, TARGET_CNT);
7073
process::exit(0);
7174
}

0 commit comments

Comments
 (0)