MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / new

Method new

cranelift/filetests/src/concurrent.rs:48–73  ·  view source on GitHub ↗

Create a new `ConcurrentRunner` with threads spun up.

()

Source from the content-addressed store, hash-verified

46impl ConcurrentRunner {
47 /// Create a new `ConcurrentRunner` with threads spun up.
48 pub fn new() -> Self {
49 let (request_tx, request_rx) = channel();
50 let request_mutex = Arc::new(Mutex::new(request_rx));
51 let (reply_tx, reply_rx) = channel();
52
53 heartbeat_thread(reply_tx.clone());
54
55 let num_threads = std::env::var("CRANELIFT_FILETESTS_THREADS")
56 .ok()
57 .map(|s| {
58 use std::str::FromStr;
59 let n = usize::from_str(&s).unwrap();
60 assert!(n > 0);
61 n
62 })
63 .unwrap_or_else(|| num_cpus::get());
64 let handles = (0..num_threads)
65 .map(|num| worker_thread(num, request_mutex.clone(), reply_tx.clone()))
66 .collect();
67
68 Self {
69 request_tx: Some(request_tx),
70 reply_rx,
71 handles,
72 }
73 }
74
75 /// Shut down worker threads orderly. They will finish any queued jobs first.
76 pub fn shutdown(&mut self) {

Callers

nothing calls this directly

Calls 9

heartbeat_threadFunction · 0.85
worker_threadFunction · 0.85
collectMethod · 0.80
newFunction · 0.50
getFunction · 0.50
cloneMethod · 0.45
mapMethod · 0.45
okMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected