Skip to content

Commit d6c15d6

Browse files
committed
fix --repeat bug with threads
1 parent c444b67 commit d6c15d6

File tree

6 files changed

+28
-21
lines changed

6 files changed

+28
-21
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "nice_api"
3-
version = "3.2.0"
3+
version = "3.2.1"
44
edition = "2021"
55
authors = ["wasabipesto <[email protected]>"]
66
description = "an api for coordinating the search for square-cube pandigitals"

client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "nice_client"
3-
version = "3.2.0"
3+
version = "3.2.1"
44
edition = "2021"
55
authors = ["wasabipesto <[email protected]>"]
66
description = "a client for distributed search of square-cube pandigitals"

client/src/main.rs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,25 @@ fn main() {
7373
// Parse command line arguments
7474
let cli = Cli::parse();
7575

76+
// Configure Rayon
77+
// This must be done outside the loop
78+
rayon::ThreadPoolBuilder::new()
79+
.num_threads(cli.threads)
80+
.build_global()
81+
.unwrap();
82+
83+
// Repeat indefinitely if requested
84+
// Otherwise, run once
85+
if cli.repeat {
86+
loop {
87+
submian(&cli);
88+
}
89+
} else {
90+
submian(&cli);
91+
}
92+
}
93+
94+
fn submian(cli: &Cli) {
7695
// Check whether to query the server for a search range or use the benchmark
7796
let claim_data = if let Some(benchmark) = cli.benchmark {
7897
get_benchmark_field(benchmark)
@@ -96,12 +115,6 @@ fn main() {
96115
let chunk_size = 100 * PROCESSING_CHUNK_SIZE;
97116
let chunks = chunked_ranges(claim_data.range_start, claim_data.range_end, chunk_size);
98117

99-
// Configure Rayon
100-
rayon::ThreadPoolBuilder::new()
101-
.num_threads(cli.threads)
102-
.build_global()
103-
.unwrap();
104-
105118
// Configure TQDM
106119
#[allow(
107120
clippy::cast_precision_loss,
@@ -155,7 +168,7 @@ fn main() {
155168
// Assemble the data package to submit to the server
156169
let submit_data = DataToServer {
157170
claim_id: claim_data.claim_id,
158-
username: cli.username,
171+
username: cli.username.clone(),
159172
client_version: CLIENT_VERSION.to_string(),
160173
unique_distribution,
161174
nice_numbers,
@@ -181,10 +194,4 @@ fn main() {
181194
Err(e) => println!("Server returned success but an error occured: {e}"),
182195
}
183196
}
184-
185-
// Repeat indefinitely if requested
186-
#[allow(clippy::main_recursion)]
187-
if cli.repeat {
188-
main();
189-
}
190197
}

common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "nice_common"
3-
version = "3.2.0"
3+
version = "3.2.1"
44
edition = "2021"
55
authors = ["wasabipesto <[email protected]>"]
66
description = "common utilities for dealing with square-cube pandigitals"

jobs/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "nice_jobs"
3-
version = "3.2.0"
3+
version = "3.2.1"
44
edition = "2021"
55
authors = ["wasabipesto <[email protected]>"]
66
description = "scheduled jobs for the nice project"

0 commit comments

Comments
 (0)