Skip to content

Commit

Permalink
fix a bug in thread spawning
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikalii committed Jun 7, 2024
1 parent 2f712e9 commit cbea7d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/primitive/defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2044,14 +2044,14 @@ primitive!(
/// : wait≡spawn/+.
///
/// For spawn threads in a thread pool, use [pool].
([1], Spawn, Thread, "spawn"),
([1], Spawn, Thread, "spawn", Impure),
/// Spawn a thread in a thread pool
///
/// Has the same functionality as [spawn], but uses a thread pool instead of spawning a new thread.
/// While [spawn]'s function will be called immediately, [pool]'s function will be called when a thread in the pool is available.
/// The thread pool has as many threads as the machine has processors.
/// If all threads in the pool are busy, then [pool] will block until a thread is available.
([1], Pool, Thread, "pool"),
([1], Pool, Thread, "pool", Impure),
/// Wait for a thread to finish and push its results to the stack
///
/// The argument must be a thread id returned by [spawn] or [pool].
Expand All @@ -2065,13 +2065,13 @@ primitive!(
/// [wait] is pervasive and will call [each] implicitly.
/// ex: ↯3_3⇡9
/// : wait≡spawn/+.
(1, Wait, Thread, "wait"),
(1, Wait, Thread, "wait", Mutating),
/// Send a value to a thread
///
/// Expects a thread id returned by [spawn] or [pool] and a value to send.
/// The thread id `0` corresponds to the parent thread.
/// The sent-to thread can receive the value with [recv] or [tryrecv].
(2(0), Send, Thread, "send"),
(2(0), Send, Thread, "send", Impure),
/// Receive a value from a thread
///
/// Expects a thread id returned by [spawn] or [pool].
Expand Down
2 changes: 1 addition & 1 deletion src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ code:
pub(crate) fn wait(&mut self, id: Value) -> UiuaResult {
let ids = id.as_natural_array(self, "Thread id must be an array of natural numbers")?;
if ids.shape.is_empty() {
let handle = ids.data.into_iter().next().unwrap();
let handle = ids.data[0];
#[cfg(not(target_arch = "wasm32"))]
let thread_stack = self
.rt
Expand Down

0 comments on commit cbea7d2

Please sign in to comment.