mirror of
https://github.com/chatmail/core.git
synced 2026-05-16 21:36:30 +03:00
Split _wait and _unref
This also removes BackupProvider::join in favour of implementing Future directly. I wondered about implementing a FusedFutre to make this a little safer but it would introduce a dependency on the futures crate in deltachat-ffi which did not exist yet, so I didn't do that.
This commit is contained in:
@@ -2706,13 +2706,21 @@ char * dc_backup_provider_qr_svg (dc_context_t* context, const dc_backup_provide
|
||||
/**
|
||||
* Waits for the sending to finish and frees the backup provider object.
|
||||
*
|
||||
* @memberof dc_backup_sender_t
|
||||
* This should only be called once.
|
||||
*
|
||||
* @memberof dc_backup_provider_t
|
||||
* @param context The context.
|
||||
* @param backup_provider The backup provider object as created by
|
||||
* dc_backup_provider_new(). If NULL is given nothing is done.
|
||||
*/
|
||||
void dc_backup_provider_wait (dc_context_t* context, dc_backup_provider_t* backup_provider);
|
||||
|
||||
/**
|
||||
* Frees a dc_backup_provider_t object.
|
||||
*
|
||||
* @memberof dc_backup_provider_t
|
||||
*/
|
||||
void dc_backup_prvider_unref (dc_backup_provider_t* backup_provider);
|
||||
|
||||
/**
|
||||
* Gets a backup offered by a dc_backup_provider_t object on another device.
|
||||
|
||||
@@ -4185,12 +4185,17 @@ pub unsafe extern "C" fn dc_backup_provider_wait(
|
||||
return;
|
||||
}
|
||||
let ctx = &*context;
|
||||
let provider = Box::from_raw(provider);
|
||||
block_on(provider.join())
|
||||
let provider = &mut *provider;
|
||||
block_on(provider)
|
||||
.log_err(ctx, "Failed to join provider")
|
||||
.ok();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_backup_provider_unref(provider: *mut dc_backup_provider_t) {
|
||||
drop(Box::from_raw(provider));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_receive_backup(
|
||||
context: *mut dc_context_t,
|
||||
|
||||
Reference in New Issue
Block a user