⌂ Modules nupp nupp.runtime nupp.runtime.services nupp.runtime.services.suspension nupp.runtime.services.suspension
Scheduler integration contract for suspension API 1.
Setup imports service here before any consumer requires nupp.suspension . The facade retains the selected functions. Source, Context, Waiting, Handler, and Installed are the shared types; providers initialize these declarations or satisfy their exact signatures without replacing their nominal identities.
A subscription may resume synchronously or later. It must settle a Waiting only once and run returned cleanup when the wait ends, including cancellation. Source release and Installed.drop must not suspend. Nested installation restores the captured handler, and transparent handlers preserve delegation to the outer scheduler. create propagates the suspension context into a new coroutine.
Sources report readiness in priority order. Context.uses identifies sources needed by a wait, while canPark distinguishes schedulers that can yield from ones that must drive readiness themselves. Cancellation values must come from nupp.runtime.services.cancellation , which preserves recognition by tasks and worker providers. State belongs to one Lua state; registrations and handlers are not copied into worker lanes.
Module contents Types Type Kind Description Contextrecord Subscription context used to register or associate readiness sources. Createtype Coroutine construction preserving arbitrary argument and result packs. Handlerrecord Scheduler integration operations with explicit Handler receivers. Installedrecord Handler restoration state owned by one installation. Providerinterface Sourcerecord Readiness registration shared with callers and handlers. Suspendtype Typed subscription operation preserving the result type T. Waitingrecord A single pending operation observed by a suspension handler.
Functions Function Kind Description destroyInstalledfunction Canonical affine cleanup for a handler installation.
Values Value Kind Description servicevariable Canonical suspension API 1 handle; setup selects before the public facade loads.
Types
Contextrecord
Subscription context used to register or associate readiness sources. A subscription may use an existing Source or create a scoped one.
Methods
source
source : function ( Context , string , integer , function ( ) : integer , ( function ( integer ) : integer ) ? ) : Source
Registers a source associated with this subscription.
Arguments Name Type Description ?Context ?string ?integer ?function ( ) : integer ?( function ( integer ) : integer ) ?
Returns
uses
Associates an existing source with this wait without changing its identity.
Arguments
Returns
canPark
canPark : function ( Context ) : boolean
Reports whether the current handler can park this subscription.
Arguments
Returns
Fields
handler
Provider-owned active handler state.
associated
Sources associated with this subscription, when explicitly tracked.
Createtype
type Create = function < A ... , R ... > ( body : function ( A ... ) : R ... ) : thread
Coroutine construction preserving arbitrary argument and result packs.
Handlerrecord
Scheduler integration operations with explicit Handler receivers. park drives or yields a wait; shutdown releases handler-owned scheduling state.
Methods
park
Parks or drives this Waiting; the callback performs subscription cleanup.
Arguments
Returns
canPark
canPark : function ( Handler ) : boolean
Reports whether this handler can park the current execution.
Arguments
Returns
shutdown
Releases scheduling state owned by this handler.
Arguments
Returns
Installedrecord
Handler restoration state owned by one installation. Its affine drop restores the outer context and releases registration state.
Methods
drop
drop : nosuspend function ( takes self : Installed ) : nil
Canonical non-suspending affine cleanup for the installation.
Arguments
Returns
release
Restores the outer handler and releases this installation.
Arguments
Returns
Fields
co
Coroutine whose handler is installed, or the provider's main-state key.
previous
Captured outer handler state restored by release.
handler
Handler supplied by the caller.
transparent
Whether operations may delegate through to the outer context.
restored
Whether the outer handler has been restored.
released
Whether installation cleanup has completed.
parks
Provider bookkeeping for waits owned by this installation.
Providerinterface
Methods
source
source : function (
name : string ,
priority : integer ,
poll : function ( ) : integer ,
wait : ( function ( integer ) : integer ) ? ,
active : ( function ( Source ) : boolean ) ?
) : Source
Registers a named poll source with a priority and optional blocking waiter. The optional active predicate controls whether the source can make progress.
Arguments Name Type Description namestring priorityinteger pollfunction ( ) : integer wait( function ( integer ) : integer ) ? active( function ( Source ) : boolean ) ?
Returns
poll
poll : function ( ) : integer
Polls registered sources and returns the amount of progress reported.
Returns
install
Installs a handler and returns affine restoration state.
Arguments Name Type Description handlerHandler transparentboolean ?
Returns
handled
handled : function ( ) : boolean
Reports whether an installed handler owns the current suspension context.
Returns
delegatedCanPark
delegatedCanPark : function ( ) : function ( ) : boolean
Captures the outer handler's park-availability query.
Returns Type Description function ( ) : boolean
delegatedPark
delegatedPark : function ( ) : function ( Waiting , function ( ) : nil ) : nil
Captures the outer handler's parking operation.
Returns Type Description function ( Waiting , function ( ) : nil ) : nil
canSuspend
canSuspend : function ( ) : boolean
Reports whether this execution context can perform a suspension.
Returns
Fields
suspend
Subscribes once, then waits for one typed result through the active handler.
create
Creates a coroutine preserving the active suspension context and result pack.
Sourcerecord
Readiness registration shared with callers and handlers. release must be idempotent and non-suspending; provider state tracks its lifetime.
Methods
release
Unregisters this source without suspending; repeated calls are harmless.
Arguments
Returns
releaseImpl
releaseImpl : function ( Source ) : nil
Provider callback used by the canonical release method.
Arguments
Returns
Fields
name
Diagnostic identity of the readiness source.
priority
Readiness ordering key; smaller priorities are polled first.
wait
wait : ( function ( integer ) : integer ) ?
Optional bounded blocking waiter receiving milliseconds and returning progress.
active
active : ( function ( Source ) : boolean ) ?
Optional predicate deciding whether the source has outstanding work.
sequence
Stable registration-order tie breaker used by the provider.
poller
poller : ( function ( ) : integer ) ?
Provider-owned nonblocking readiness callback.
waiter
waiter : ( function ( integer ) : integer ) ?
Provider-owned blocking readiness callback.
released
Whether the registration has already been released.
Suspendtype
type Suspend = function < T > ( operation : string , subscribe : function ( function ( T ) , Context ) : ( function ( ) ? ) ) : T
Typed subscription operation preserving the result type T. The subscription returns optional cleanup and may resume synchronously.
Waitingrecord
A single pending operation observed by a suspension handler. ready is monotonic once resumed; onResume installs the handler's wake callback.
Methods
ready
Reports whether the subscription has settled.
Arguments
Returns
onResume
onResume : function ( Waiting , function ( ) : nil ) : nil
Registers a wake callback for the waiting scheduler.
Arguments Name Type Description ?Waiting ?function ( ) : nil
Returns
Fields
operation
Diagnostic operation name supplied to suspend.
state
Provider-owned settlement and subscription state.
Functions
destroyInstalledfunction
Canonical affine cleanup for a handler installation.
Arguments
Returns
Values
servicevariable
Canonical suspension API 1 handle; setup selects before the public facade loads.
← Previous nupp.runtime.services.process Next → nupp.runtime.services.system