From a4f45f709278208cb61501df2792412f11aed3c4 Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Mon, 11 Dec 2023 20:10:33 -0700 Subject: perf(ext/ffi): switch from middleware to tasks (#21239) Deno-side changes for https://github.com/denoland/deno_core/pull/350 --------- Co-authored-by: Aapo Alasuutari --- test_ffi/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test_ffi/src') diff --git a/test_ffi/src/lib.rs b/test_ffi/src/lib.rs index b1a210417..c5c2c2d7a 100644 --- a/test_ffi/src/lib.rs +++ b/test_ffi/src/lib.rs @@ -258,6 +258,20 @@ pub extern "C" fn call_stored_function_thread_safe_and_log() { }); } +#[no_mangle] +pub extern "C" fn call_stored_function_2_thread_safe(arg: u8) { + std::thread::spawn(move || { + std::thread::sleep(std::time::Duration::from_millis(1500)); + unsafe { + if STORED_FUNCTION_2.is_none() { + return; + } + println!("Calling"); + STORED_FUNCTION_2.unwrap()(arg); + } + }); +} + #[no_mangle] pub extern "C" fn log_many_parameters( a: u8, -- cgit v1.2.3