Skip to main content

Crate bun_threading

Crate bun_threading 

Source
Expand description

bun_threading crate root — thin re-exports mirroring src/threading/threading.zig.

Re-exports§

pub use channel::Channel;
pub use condition::Condition;
pub use condition::Condvar;
pub use futex as Futex;
pub use guarded::Debug as DebugGuarded;
pub use guarded::RawMutex;
pub use guarded::Guarded;
pub use guarded::GuardedBy;
pub use guarded::GuardedLock;
pub use mutex::Mutex;
pub use mutex::MutexGuard;
pub use reset_event::ResetEvent;
pub use rwlock::RwLock;
pub use rwlock::RwLockReadGuard;
pub use rwlock::RwLockWriteGuard;
pub use semaphore::Semaphore;
pub use thread_pool::ThreadPool;
pub use unbounded_queue::Linked;
pub use unbounded_queue::UnboundedQueue;
pub use wait_group::WaitGroup;
pub use work_pool::Task as WorkPoolTask;
pub use work_pool::IntrusiveWorkTask;
pub use work_pool::OwnedTask;
pub use work_pool::WorkPool;

Modules§

channel
condition
Copy of std.Thread.Condition, but uses Bun’s Mutex and Futex. Synchronized with std as of Zig 0.14.1.
futex
This is a copy-pasta of std.Thread.Futex, except without unreachable Synchronized with std as of Zig 0.14.1
guarded
A wrapper around a mutex, and a value protected by the mutex.
mutex
This is a copy-pasta of std.Thread.Mutex with some changes.
reset_event
Port of std.Thread.ResetEvent (Zig 0.14.1) on top of Bun’s Futex.
rwlock
A lock that supports one writer or many readers.
semaphore
Port of std.Thread.Semaphore (Zig 0.14.1) on top of Bun’s Mutex + Condition. A semaphore is an unsigned integer that blocks the calling thread when it would go negative.
thread_pool
unbounded_queue
wait_group
work_pool

Macros§

intrusive_work_task
Implements IntrusiveWorkTask for a struct that embeds an intrusive task: Task field. Expands to bun_core::intrusive_field! + a marker impl; brings IntrusiveWorkTask::from_task_ptr into scope for the type’s fn(*mut Task) trampolines.
owned_task
Implements OwnedTask (and the required Send) for a struct that embeds an intrusive task: Task field and is scheduled fire-and-forget via WorkPool::schedule_owned. Expands to [intrusive_work_task!] + unsafe impl Send + the run forward — the implementor supplies only an inherent fn run_owned(self: Box<Self>).

Structs§

Once
parking_lot::Once parity. Bun has no custom Once (Zig also uses std.once directly), and std::sync::Once has no poisoning concern, so just re-export it for callers migrating off parking_lot::Once. A low-level synchronization primitive for one-time global execution.

Functions§

current_thread_id
Port of std.Thread.getCurrentId() — returns a non-zero OS thread id. Used by Mutex debug deadlock detection and Condition (Windows).