Skuld.Comp.InternalSuspend (skuld v0.2.3)
View SourceInternal suspension for Env-aware code.
Unlike Comp.ExternalSuspend (which closes over env for external callbacks),
this suspension receives env at resume time, allowing callers to
supply an updated env when resuming.
Two Kinds of Suspension
External suspension (Comp.ExternalSuspend):
resume :: (val) -> {result, env}- Closes over env at suspension point
- For passing to external code that doesn't understand Skuld's env threading
Internal suspension (Comp.InternalSuspend):
resume :: (val, env) -> {result, env}- Does NOT close over env - receives it at resume time
- For schedulers/handlers that need to thread updated env through suspensions
Payload Types
The payload field contains a struct that identifies the kind of suspension:
Batch- batchable operations (DB fetches, etc.)Channel- channel put/take operationsAwait- fiber await operations
Summary
Functions
Create an await-all suspension.
Create an await-any suspension.
Create an await-one suspension.
Create a batch operation suspension.
Create a channel put suspension.
Create a channel take suspension.
Types
@type payload() ::
Skuld.Comp.InternalSuspend.Batch.t()
| Skuld.Comp.InternalSuspend.Channel.t()
| Skuld.Comp.InternalSuspend.Await.t()
@type t() :: %Skuld.Comp.InternalSuspend{ payload: payload(), resume: (term(), Skuld.Comp.Types.env() -> {term(), Skuld.Comp.Types.env()}) }
Functions
@spec await_all([Skuld.Fiber.Handle.t()], Skuld.Comp.Types.k()) :: t()
Create an await-all suspension.
@spec await_any([Skuld.Fiber.Handle.t()], Skuld.Comp.Types.k()) :: t()
Create an await-any suspension.
@spec await_one(Skuld.Fiber.Handle.t(), Skuld.Comp.Types.k(), keyword()) :: t()
Create an await-one suspension.
@spec batch(term(), reference(), Skuld.Comp.Types.k()) :: t()
Create a batch operation suspension.
@spec channel_put(reference(), term(), Skuld.Comp.Types.k()) :: t()
Create a channel put suspension.
@spec channel_take(reference(), Skuld.Comp.Types.k()) :: t()
Create a channel take suspension.