baml.spawn.Limit
Caps how many tasks spawned `with` it run at once.
Signature
class baml.spawn.LimitCaps how many tasks spawned with it run at once.
Tasks over the cap wait in line; the spawn still returns its Future at
once. A waiting task can be cancelled. A task spawned with several limits
starts once every one of them has room, and holds none of them while it
waits. Two spawns share a cap only if they use the same Limit value, and
a spawn that lists the same limit twice takes one slot.
Examples
let provider = baml.spawn.Limit.new(8);
let futures = ids.map((id) -> { spawn with provider { fetch(id) } });
Source:<builtin>/baml/ns_spawn/spawn.bamlbytes 5293–6058
Fields
_handle
$rust_typeStatic methods
Creates a limit that admits capacity tasks at a time.
Throws
InvalidArgument if capacity is not positive.
Instance methods
active_count
(self) -> int throws neverHow many tasks hold a slot right now.
capacity
(self) -> int throws neverHow many tasks this limit admits at a time.
queued_count
(self) -> int throws neverHow many tasks are waiting for a slot right now.
Implementations
baml.Concrete for T
Static methods
type
() -> reflect.Type throws neverThis type's runtime type value: int.type() is the same value as
reflect.Type.of<int>().
Spell it on a declared type written as one name, optionally qualified
or with generic arguments: Foo.type(), root.models.Base.type(),
Box<int[]>.type(). Array, optional, union, map and function types,
interfaces, and generic type parameters keep the reflect.Type.of<T>()
form. A type that declares its own type member keeps resolving to it.
Source:<builtin>/baml/core.bamlbytes 1360–1392
baml.spawn.Modifier for baml.spawn.Limit
Output = TError = EApplyError = neverInstance methods
Source:<builtin>/baml/ns_spawn/spawn.bamlbytes 6451–6635