pub unsafe fn with_capacity(
        env: Env,
        max_queue_size: usize,
        callback: fn(Option<Env>, T),
    ) -> Self {
        let mut result = MaybeUninit::uninit();
        let is_finalized = Arc::new(Mutex::new(false));

        assert_eq!(
            napi::create_threadsafe_function(
                env,
                std::ptr::null_mut(),
                std::ptr::null_mut(),
                string(env, "neon threadsafe function"),
                max_queue_size,
                // Always set the reference count to 1. Prefer using
                // Rust `Arc` to maintain the struct.
                1,
                Arc::into_raw(is_finalized.clone()) as *mut _,
                Some(Self::finalize),
                std::ptr::null_mut(),
                Some(Self::callback),
                result.as_mut_ptr(),
            ),
            napi::Status::Ok,
        );

        Self {
            tsfn: Tsfn(result.assume_init()),
            is_finalized: is_finalized,
            callback,
        }
    }
/// Creates a bounded N-API Threadsafe Function
/// Safety: `Env` must be valid for the current thread
Creates a bounded N-API Threadsafe Function
Safety: `Env` must be valid for the current thread
Creates a bounded N - API Threadsafe Function Safety : ` Env ` must be valid for the current thread
pub unsafe fn with_capacity(
        env: Env,
        max_queue_size: usize,
        callback: fn(Option<Env>, T),
    ) -> Self {
        let mut result = MaybeUninit::uninit();
        let is_finalized = Arc::new(Mutex::new(false));
        assert_eq!(
            napi::create_threadsafe_function(
                env,
                std::ptr::null_mut(),
                std::ptr::null_mut(),
                string(env, "neon threadsafe function"),
                max_queue_size,
                // Always set the reference count to 1. Prefer using
                // Rust `Arc` to maintain the struct.
                1,
                Arc::into_raw(is_finalized.clone()) as *mut _,
                Some(Self::finalize),
                std::ptr::null_mut(),
                Some(Self::callback),
                result.as_mut_ptr(),
            ),
            napi::Status::Ok,
        );
        Self {
            tsfn: Tsfn(result.assume_init()),
            is_finalized: is_finalized,
            callback,
        }
    }
pub unsafe fn with_capacity ( env : Env , max_queue_size : usize , callback : fn ( Option < Env > , T ) , ) -> Self { let mut result = MaybeUninit :: uninit ( ) ; let is_finalized = Arc :: new ( Mutex :: new ( false ) ) ; assert_eq ! ( napi create_threadsafe_function ( env std ptr null_mut ( ) std ptr null_mut ( ) string ( env " " ) max_queue_size // Always set the reference count to 1. Prefer using // Rust `Arc` to maintain the struct. 1 Arc into_raw ( is_finalized clone ( ) ) as mut Some ( Self finalize ) std ptr null_mut ( ) Some ( Self callback ) result as_mut_ptr ( ) ) napi Status Ok ) ; Self { tsfn : Tsfn ( result . assume_init ( ) ) , is_finalized : is_finalized , callback , } }
Creates a bounded N-API Threadsafe Function
Safety: `Env` must be valid for the current thread
Creates a bounded N - API Threadsafe Function Safety : ` Env ` must be valid for the current thread
env
Env
max_queue_size
usize
callback
fn(Option<Env>, T)