mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 05:16:28 +03:00
Add dc_event_emitter_close() API
dc_event_emitter_close() can be used to terminate event loop from another thread without dereferencing the context which may be in use by the event loop at the same time.
This commit is contained in:
@@ -640,6 +640,18 @@ pub unsafe extern "C" fn dc_event_emitter_unref(emitter: *mut dc_event_emitter_t
|
||||
Box::from_raw(emitter);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_event_emitter_close(emitter: *mut dc_event_emitter_t) {
|
||||
if emitter.is_null() {
|
||||
eprintln!("ignoring careless call to dc_event_emitter_close()");
|
||||
return;
|
||||
}
|
||||
|
||||
let emitter = &mut *emitter;
|
||||
|
||||
block_on(emitter.close())
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_get_next_event(events: *mut dc_event_emitter_t) -> *mut dc_event_t {
|
||||
if events.is_null() {
|
||||
|
||||
Reference in New Issue
Block a user