Skip to content

Commit

Permalink
Address review comments:
Browse files Browse the repository at this point in the history
- typo
- fixed upper bound for num_worker_threads
  • Loading branch information
Arash Sahebolamri committed Jul 19, 2024
1 parent cbe6600 commit 4fd27d4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions intel-sgx/enclave-runner/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl<'a> EnclaveBuilder<'a> {
self
}

/// Sets the number of wroker threads used to run the enclave.
/// Sets the number of worker threads used to run the enclave.
///
/// **NOTE:** This is only applicable to [`Command`] enclaves.
/// Setting this and then calling [`build_library`](Self::build_library) will cause a panic.
Expand Down Expand Up @@ -342,10 +342,9 @@ impl<'a> EnclaveBuilder<'a> {
}

pub fn build<T: Load>(mut self, loader: &mut T) -> Result<Command, anyhow::Error> {
let num_cpus = num_cpus::get();
let num_worker_threads = self.num_worker_threads.unwrap_or(num_cpus);
let num_worker_threads = self.num_worker_threads.unwrap_or_else(num_cpus::get);
anyhow::ensure!(num_worker_threads > 0, "`num_worker_threads` cannot be zero");
anyhow::ensure!(num_worker_threads <= num_cpus, "`num_worker_threads` cannot exceed number of logical cores (`num_cpus::get()`)");
anyhow::ensure!(num_worker_threads <= 512, "`num_worker_threads` cannot exceed 512");

self.initialized_args_mut();
let args = self.cmd_args.take().unwrap_or_default();
Expand Down

0 comments on commit 4fd27d4

Please sign in to comment.