chore(napi): add UnwindSafe and RefUnwindSafe back to AbortSignal and AsyncWorkPromise (#2789)

This commit is contained in:
LongYinan 2025-07-21 16:03:24 +08:00 committed by GitHub
parent 1ca2bad43f
commit 16dbf68dca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -2,6 +2,7 @@ use std::cell::Cell;
use std::marker::PhantomData;
use std::mem;
use std::os::raw::c_void;
use std::panic::UnwindSafe;
use std::ptr;
use std::rc::Rc;
@ -31,6 +32,9 @@ pub struct AsyncWorkPromise<T> {
_phantom: PhantomData<T>,
}
impl<T> UnwindSafe for AsyncWorkPromise<T> {}
impl<T> std::panic::RefUnwindSafe for AsyncWorkPromise<T> {}
impl<T> AsyncWorkPromise<T> {
pub fn promise_object<'env>(&self) -> PromiseRaw<'env, T> {
PromiseRaw::new(self.env, self.raw_promise)

View File

@ -1,8 +1,8 @@
use std::cell::Cell;
use std::ffi::c_void;
use std::marker::PhantomData;
use std::ptr;
use std::rc::Rc;
use std::{cell::Cell, panic::UnwindSafe};
use crate::{
async_work,
@ -56,6 +56,9 @@ pub struct AbortSignal {
status: Rc<Cell<u8>>,
}
impl UnwindSafe for AbortSignal {}
impl std::panic::RefUnwindSafe for AbortSignal {}
#[repr(transparent)]
struct AbortSignalStack(Vec<AbortSignal>);