Skip to content

Commit c63dee0

Browse files
committed
zephyr: sys: thread: Fix self argument to spawn
Fix the self argument to spawn. This fixes a safety problem with threads. Spawn should take a `self` to consume the thread once it has been spawned, otherwise it is possible to spawn multiple times. Signed-off-by: David Brown <[email protected]>
1 parent 5eb7283 commit c63dee0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

zephyr/src/sys/thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ impl StaticThread {
423423
#[cfg(CONFIG_RUST_ALLOC)]
424424
/// Spawn a thread, running a closure. The closure will be boxed to give to the new thread.
425425
/// The new thread runs immediately.
426-
pub fn spawn<F: FnOnce() + Send + 'static>(&self, stack: StackToken, child: F) -> Thread {
426+
pub fn spawn<F: FnOnce() + Send + 'static>(self, stack: StackToken, child: F) -> Thread {
427427
let child: closure::Closure = Box::new(child);
428428
let child = Box::into_raw(Box::new(closure::ThreadData {
429429
closure: ManuallyDrop::new(child),

0 commit comments

Comments
 (0)