Available
amalgame-threading
Mutex, Channel, Thread.Spawn — wraps pthread.
Overview
Cross-OS concurrency primitives: threads, mutexes, bounded FIFO channels. Wraps pthread on Linux/macOS and Win32 Threads on Windows. GC-safe registration for Boehm GC. The layer that makes Mosaic's worker pool possible.
Features
- ✓
Thread.Spawn(fn)/Join()/Sleep(ms) - ✓
Mutex.New(),Lock(),Unlock() - ✓Bounded FIFO
Channel<T>.New(capacity) - ✓Internal condition variables for
Channel - ✓GC-safe registration under pthread/Win32
Example
Minimal usage example — copy-paste runnable after install.
amc package add threading
let ch = Channel<int>.New(16)
Thread.Spawn(fn() {
for i in 0..10 { ch.Send(i) }
ch.Close()
})
while let v = ch.Recv() {
Console.WriteLine(v)
}
At a glance
- License: Apache-2.0
- Install:
amc package add threading - Source: amalgame-lang/amalgame-threading
- Official index: amalgame-lang/packages-index