mirror of
https://github.com/fluencelabs/marine-rs-sdk
synced 2025-03-15 06:20:50 +00:00
use Any instead of Drop
This commit is contained in:
parent
37cfd15543
commit
e671e835a8
@ -22,11 +22,12 @@ use super::log;
|
||||
|
||||
use std::sync::atomic::AtomicUsize;
|
||||
use std::cell::RefCell;
|
||||
use std::any::Any;
|
||||
|
||||
static mut RESULT_PTR: AtomicUsize = AtomicUsize::new(0);
|
||||
static mut RESULT_SIZE: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
thread_local!(static OBJECTS_TO_RELEASE: RefCell<Vec<Box<dyn Drop>>> = RefCell::new(Vec::new()));
|
||||
thread_local!(static OBJECTS_TO_RELEASE: RefCell<Vec<Box<dyn Any>>> = RefCell::new(Vec::new()));
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe fn get_result_ptr() -> usize {
|
||||
@ -72,7 +73,7 @@ pub unsafe fn release_objects() {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn add_object_to_release(object: Box<dyn Drop>) {
|
||||
pub fn add_object_to_release(object: Box<dyn Any>) {
|
||||
OBJECTS_TO_RELEASE.with(|objects| {
|
||||
let mut objects = objects.borrow_mut();
|
||||
objects.push(object);
|
||||
|
@ -144,6 +144,7 @@ fn generate_mem_forget(
|
||||
let passing_style = ret_type.as_ref().map(passing_style_of);
|
||||
|
||||
match passing_style {
|
||||
// result will be deleted by IT side
|
||||
Some(PassingStyle::ByValue) => quote! { std::mem::forget(result); },
|
||||
Some(PassingStyle::ByRef) | Some(PassingStyle::ByMutRef) => {
|
||||
mem_forget_by_args(args, converted_args)
|
||||
@ -166,7 +167,6 @@ fn mem_forget_by_args(
|
||||
PassingStyle::ByValue => {}
|
||||
_ => res.extend(quote! {
|
||||
fluence::internal::add_object_to_release(Box::new(#converted_arg));
|
||||
std::mem::forget(#converted_arg);
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user