Skip to main content

EventLoopHandle

Enum EventLoopHandle 

Source
pub enum EventLoopHandle {
    Js {
        owner: JsEventLoop,
    },
    Mini(BackRef<MiniEventLoop<'static>>),
}

Variants§

§

Js

Fields

§owner: JsEventLoop

Typed handle wrapping the erased *mut jsc::EventLoop — see AnyEventLoop::Js. JsEventLoop is Copy, so the handle stays Copy.

§

Mini(BackRef<MiniEventLoop<'static>>)

Implementations§

Source§

impl EventLoopHandle

Source

pub fn init(js_event_loop: *mut ()) -> EventLoopHandle

Wrap an erased *mut jsc::EventLoop.

js_event_loop is a live erased *mut jsc::EventLoop whose owner outlives every dispatch through the returned handle. The pointer is not dereferenced here — it’s stored opaquely in JsEventLoop and only dereferenced at dispatch sites. A null pointer is a documented sentinel for “never dispatched” placeholders (e.g. struct field initialisers that are overwritten before use).

Source

pub fn init_mini(mini: *mut MiniEventLoop<'static>) -> EventLoopHandle

Source

pub fn as_event_loop_ctx(self) -> EventLoopCtx

Source

pub fn into_tag_ptr(self) -> (i8, *mut c_void)

Erase to the (tag, ptr) pair stored in uws::InternalLoopData (parent_tag / parent_ptr). Tag 1 = JS, tag 2 = mini — matches Zig setParentEventLoop.

Source

pub unsafe fn from_tag_ptr(tag: i8, ptr: *mut c_void) -> EventLoopHandle

Inverse of [into_tag_ptr] — recover from the (tag, ptr) pair stored in uws::InternalLoopData (Zig: loop.internal_loop_data.getParent()).

(tag, ptr) must have been produced by [into_tag_ptr] on a still-live event loop (i.e. read from internal_loop_data while the loop is alive).

§Safety

(tag, ptr) must have been produced by [into_tag_ptr] on a still-live event loop. The constructor itself only stores the opaque pointer, but dispatch through the resulting handle dereferences it — this fn is the last place the precondition can be discharged. (NOT eligible for unsafe-fn-narrow: the invariant is caller-provided, not internally guarded.)

Source§

impl EventLoopHandle

Source

pub fn set_as_parent_of(self, uws_loop: &mut PosixLoop)

Zig: loop.internal_loop_data.setParentEventLoop(jsc.EventLoopHandle.init(..)). Convenience wrapper so callers don’t need both bun_uws::InternalLoopDataExt (the trait) and the *mut Loop deref dance in scope. uws_loop is the process-global loop returned by AnyEventLoop::r#loop() — never null.

Source

pub fn from_any(any: &mut AnyEventLoop<'static>) -> EventLoopHandle

Source

pub fn js_current() -> EventLoopHandle

EventLoopHandle for the current thread’s JS event loop. Replaces jsc::EventLoopHandle.init(jsc::VirtualMachine.get()) for tier-≤4 callers.

Source

pub fn global_object(self) -> *mut ()

Erased *mut jsc::JSGlobalObject or null (Mini has no JS global).

Source

pub fn bun_vm(self) -> *mut ()

Erased *mut jsc::VirtualMachine or null.

Source

pub fn stdout(self) -> *mut ()

Erased *mut webcore::blob::Store.

Source

pub fn stderr(self) -> *mut ()

Erased *mut webcore::blob::Store.

Source

pub fn enter(self)

Source

pub fn exit(self)

Source

pub fn entered(self) -> EnteredEventLoop

enter() and return an RAII guard that exit()s on drop. Prefer this over a bare enter()/exit() pair so early returns and ? don’t leak the entered scope.

Source

pub fn file_polls(self) -> *mut Store

Returns the FilePoll store as a raw pointer (mirrors Zig *FilePoll.Store). EventLoopHandle is Copy; promoting to &'static mut would let two calls produce aliased exclusive references (UB). Callers deref locally for the brief region they need &mut.

Source

pub fn put_file_poll(&mut self, poll: &mut FilePoll)

Source

pub fn enqueue_task_concurrent(self, task: EventLoopTaskPtr)

Source

pub fn loop(self) -> *mut PosixLoop

Source

pub fn platform_event_loop(self) -> *mut PosixLoop

Source

pub fn loop_(self) -> *mut PosixLoop

Alias for r#loop so callers spell handle.loop_() without the raw-identifier escape (Zig: handle.loop()).

Source

pub fn native_loop(self) -> *mut PosixLoop

Platform-native loop pointer (us_loop_t* on POSIX, uv_loop_t* on Windows). See bun_io::uws_to_native — collapses the per-site #[cfg(windows)] .uv_loop projection that previously appeared at every BufferedReaderParent::loop_ impl.

Source

pub fn pipe_read_buffer(self) -> *mut [u8]

Returns the shared pipe-read scratch buffer as a raw fat ptr (mirrors Zig []u8). Same Copy-handle aliasing concern as [file_polls].

Source

pub fn ref_(self)

Source

pub fn unref(self)

Source

pub fn env(self) -> *mut Loader<'static>

Source

pub fn top_level_dir(self) -> &'static [u8] ⓘ

Source

pub fn create_null_delimited_env_map( self, ) -> Result<NullDelimitedEnvMap, AllocError>

Trait Implementations§

Source§

impl Clone for EventLoopHandle

Source§

fn clone(&self) -> EventLoopHandle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for EventLoopHandle

Source§

impl ParentEventLoopHandle for EventLoopHandle

Carrier-trait impl so bun_uws::InternalLoopDataExt::set_parent_event_loop accepts EventLoopHandle directly. Kept here (not in bun_uws) because bun_uws is a lower tier than bun_event_loop and cannot name this enum.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsCtxPtr for T
where T: ?Sized,

Source§

fn as_ctx_ptr(&self) -> *mut Self
where Self: Sized,

self’s address as *mut Self for deferred-task / scopeguard / ref_guard ctx slots. The closures/trampolines deref it as shared (&*p) — every method they reach is &self post-R-2, so no write provenance is required; the *mut spelling is purely to match the existing DerefOnDrop / HasAutoFlush / RefCount ABI.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V