Skip to content

Commit 8dbaf5d

Browse files
committed
test(runtime): stop run loop in CFRunLoopPerformBlock
1 parent 94208a5 commit 8dbaf5d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compio-runtime/tests/custom_loop.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn cf_run_loop() {
1414
use core_foundation::{
1515
base::TCFType,
1616
filedescriptor::{kCFFileDescriptorReadCallBack, CFFileDescriptor, CFFileDescriptorRef},
17-
runloop::{kCFRunLoopDefaultMode, CFRunLoop, CFRunLoopRef},
17+
runloop::{kCFRunLoopDefaultMode, CFRunLoop, CFRunLoopRef, CFRunLoopStop},
1818
string::CFStringRef,
1919
};
2020

@@ -77,8 +77,12 @@ fn cf_run_loop() {
7777

7878
let event = Event::new();
7979
let handle = Arc::new(Mutex::new(Some(event.handle())));
80+
let run_loop = CFRunLoop::get_current();
8081
let block = StackBlock::new(move || {
8182
handle.lock().unwrap().take().unwrap().notify();
83+
unsafe {
84+
CFRunLoopStop(run_loop.as_concrete_TypeRef());
85+
}
8286
});
8387
extern "C" {
8488
fn CFRunLoopPerformBlock(rl: CFRunLoopRef, mode: CFStringRef, block: &Block<dyn Fn()>);

0 commit comments

Comments
 (0)