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::Link;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
unreachableSynchronized 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’sFutex. - rwlock
- A lock that supports one writer or many readers.
- semaphore
- Port of
std.Thread.Semaphore(Zig 0.14.1) on top of Bun’sMutex+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
IntrusiveWorkTaskfor a struct that embeds an intrusivetask: Taskfield. Expands tobun_core::intrusive_field!+ a marker impl; bringsIntrusiveWorkTask::from_task_ptrinto scope for the type’sfn(*mut Task)trampolines. - owned_
task - Implements
OwnedTask(and the requiredSend) for a struct that embeds an intrusivetask: Taskfield and is scheduled fire-and-forget viaWorkPool::schedule_owned. Expands to [intrusive_work_task!] +unsafe impl Send+ therunforward — the implementor supplies only an inherentfn run_owned(self: Box<Self>).
Structs§
- Once
parking_lot::Onceparity. Bun has no customOnce(Zig also usesstd.oncedirectly), andstd::sync::Oncehas no poisoning concern, so just re-export it for callers migrating offparking_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 byMutexdebug deadlock detection andCondition(Windows).