summaryrefslogtreecommitdiff
path: root/test_ffi/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'test_ffi/src/lib.rs')
-rw-r--r--test_ffi/src/lib.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/test_ffi/src/lib.rs b/test_ffi/src/lib.rs
index b4908d9cd..d6f29cbb8 100644
--- a/test_ffi/src/lib.rs
+++ b/test_ffi/src/lib.rs
@@ -211,6 +211,19 @@ pub extern "C" fn call_stored_function_2(arg: u8) {
}
}
+#[no_mangle]
+pub extern "C" fn call_stored_function_thread_safe() {
+ std::thread::spawn(move || {
+ std::thread::sleep(std::time::Duration::from_millis(1500));
+ unsafe {
+ if STORED_FUNCTION.is_none() {
+ return;
+ }
+ STORED_FUNCTION.unwrap()();
+ }
+ });
+}
+
// FFI performance helper functions
#[no_mangle]
pub extern "C" fn nop() {}