Skip to main content

Module MiniEventLoop

Module MiniEventLoop 

Source
Expand description

MiniEventLoop: A lightweight event loop for non-JavaScript contexts

This is a simplified version of jsc.EventLoop that provides event loop functionality without requiring a JavaScript runtime. It enables code reuse between JavaScript-enabled contexts (like bun run) and JavaScript-free contexts (like bun build, bun install, and the Bun Shell).

Key characteristics:

  • Wraps the uSockets event loop, same as jsc.EventLoop
  • Supports concurrent task execution via thread pools
  • Provides file polling capabilities for watching filesystem changes
  • Manages stdout/stderr streams without JavaScript bindings
  • Handles environment variable loading and management

Use cases:

  • Build processes that need async I/O without JavaScript execution
  • Package installation with concurrent network requests
  • Shell command execution with proper I/O handling
  • Any Bun subsystem that needs event-driven architecture without JS overhead

Structs§

JsKind
MiniEventLoop
MiniKind
MiniVM

Enums§

EventLoopKind

Constants§

GLOBAL
GLOBAL_INITIALIZED
PIPE_READ_BUFFER_SIZE

Traits§

AbstractVM
Zig AbstractVM(inner: anytype) dispatches on @TypeOf(inner) to wrap either a *VirtualMachine or a *MiniEventLoop. Rust models this as a trait implemented for both.
EventLoopKindT

Functions§

__bun_stdio_blob_store_new
Constructs a webcore::blob::Store for stdout/stderr/stdin (Zig rare_data.zig:551 inline Blob.Store ctor). Return value is an erased *mut blob::Store with intrusive refcount = 2; this crate only stores/forwards it. Defined in bun_runtime::webcore::blob. No caller-side preconditions (by-value args, allocates fresh).
init_global
Returns the thread-local *mut MiniEventLoop (Zig: *MiniEventLoop).

Type Aliases§

ConcurrentTaskQueue
Intrusive MPSC queue over AnyTaskWithExtraContext linked via its .next field.
PipeReadBuffer
PlatformEventLoop
The platform’s native event loop type. Zig: jsc.PlatformEventLoop.
Task