From 3da182b0b86d93000d4473188f361ffa2de9fb73 Mon Sep 17 00:00:00 2001 From: Aapo Alasuutari Date: Sat, 9 Jul 2022 12:49:20 +0300 Subject: fix(ext/ffi): Avoid keeping JsRuntimeState RefCell borrowed for event loop middleware calls (#15116) --- test_ffi/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test_ffi/src/lib.rs') diff --git a/test_ffi/src/lib.rs b/test_ffi/src/lib.rs index d6f29cbb8..257a47368 100644 --- a/test_ffi/src/lib.rs +++ b/test_ffi/src/lib.rs @@ -224,6 +224,20 @@ pub extern "C" fn call_stored_function_thread_safe() { }); } +#[no_mangle] +pub extern "C" fn call_stored_function_thread_safe_and_log() { + std::thread::spawn(move || { + std::thread::sleep(std::time::Duration::from_millis(1500)); + unsafe { + if STORED_FUNCTION.is_none() { + return; + } + STORED_FUNCTION.unwrap()(); + println!("STORED_FUNCTION called"); + } + }); +} + // FFI performance helper functions #[no_mangle] pub extern "C" fn nop() {} -- cgit v1.2.3