Skip to content

Commit 0fa23b2

Browse files
committed
feat(godot-ffi): stub is_main_thread() for wasm_nothread
1 parent 0c1ea72 commit 0fa23b2

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

godot-core/src/task/async_runtime.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ pub fn spawn(future: impl Future<Output = ()> + 'static) -> TaskHandle {
9595
// By limiting async tasks to the main thread we can redirect all signal callbacks back to the main thread via `call_deferred`.
9696
//
9797
// Once thread-safe futures are possible the restriction can be lifted.
98-
#[cfg(not(wasm_nothreads))]
9998
assert!(
10099
crate::init::is_main_thread(),
101100
"godot_task() can only be used on the main thread"

godot-ffi/src/lib.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,17 @@ pub fn main_thread_id() -> std::thread::ThreadId {
435435
///
436436
/// # Panics
437437
/// - If it is called before the engine bindings have been initialized.
438-
#[cfg(not(wasm_nothreads))]
438+
///
439439
pub fn is_main_thread() -> bool {
440-
std::thread::current().id() == main_thread_id()
440+
#[cfg(not(wasm_nothreads))]
441+
{
442+
std::thread::current().id() == main_thread_id()
443+
}
444+
445+
#[cfg(wasm_nothreads)]
446+
{
447+
true
448+
}
441449
}
442450

443451
// ----------------------------------------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)