Skip to content
Beskid Platform specification

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

Concurrency package - Design model

Platform spec article

Concurrency package - Design model

Spec standingStandard

Owner
Piotr Mikstacki
Submitter
Piotr Mikstacki

Workspace package corelib_concurrency (directory compiler/corelib/packages/concurrency/) with one primary module file per public type (match existing corelib style: System/Syscall/ split).

Module pathResponsibility
Concurrency.FiberFiber<T> struct; event OnCancelled() on handle; Join, Detach, Cancel
Concurrency.ChannelChannel<T>; Send, Receive, TrySend, TryReceive, Close
Concurrency.ChannelOptionsBounded(capacity), Unbounded, optional SingleReader / SingleWriter flags
Concurrency.HubHub<T> homogeneous; Register, WaitReceive (round-robin)
Concurrency.HubReceiveResultindex + value: T
Concurrency.MutexLock, TryLock, Unlock
Concurrency.WaitGroupAdd, Done, Wait
ConcurrencyYield, NowMillis, ProcessorCount, SetProcessorCount

Prelude re-exports (optional, versioned): only what most apps need—avoid dumping the whole package into Prelude.bd until stable.

Runtime status values are split by namespace. Concurrency.Status is only for channel, hub, mutex, and wait-group paths: Ok = 0, Closed = 1, Cancelled = 2, WouldBlock = 3, HubEmpty = 4, HubLimit = 5, HubNotFound = 6, and MutexBusy = 1 for try-lock. Concurrency.FiberJoinStatus is a separate join namespace: Ok = 0, Cancelled = 1, Panicked = 2, StackOverflow = 3, and NotDone = 4.

Fiber Join mappings must never compare join results against channel/hub status constants. Hub Register and WaitReceive map only hub-specific statuses to HubError.

Each public method maps 1:1 to a runtime builtin or a small inline sequence documented in Channels and synchronization. No intermediate “scheduler interface” trait hierarchy in Beskid source.

Runtime fiber switching may follow a stack-switching coroutine design (see Building lightweight coroutines in Rust (fibers) for engineering patterns). The normative contract remains this platform spec and ABI symbols, not the article.

  • Parallel .NET-style stacks (Task, ValueTask, ChannelReader/ChannelWriter split types in user API)
  • Hidden async/await lowering
  • Second channel abstraction in System.* outside this package