Silk

silk/scheduler

Provider protocol for preparing and atomically publishing child Fibers.

When to use

Implement Scheduler to supply task policy for Fiber.forkChild. Application code normally uses Fiber operations instead of this provider protocol.

Details

prepare allocates and prepares one child but does not publish it. The returned PendingPublication owns the complete task submission, response channel, and eventual affine Fiber. Fiber.forkChild registers that data after the exclusive service dispatch has ended.

Gotchas

A provider must not expose the Fiber before publication succeeds. Publication failure consumes the complete pending value and returns no Fiber.

Import as Scheduler with import silk.scheduler.

Public declarations: 17.

TaskId

pub struct TaskId

A task identity that is unique within one Scheduler execution.

Details

A provider reserves identities monotonically and does not reuse them during one execution.

Field value

pub value: u64

The provider-local monotonic identity value.

Implementation Copy for TaskId

impl Copy for TaskId

Implementation HashKey for TaskId

impl HashKey for TaskId

Operation equals

equals = TaskId.taskIdEquals

Operation hash

hash = TaskId.taskIdHash

TaskIdExhaustedError

pub struct TaskIdExhaustedError

A typed failure that reports exhaustion of the task identity space.

PublicationResponse

pub struct PublicationResponse

A response that records whether one prepared child was published or rejected.

Details

The parent owns this cell while parked. The Scheduler driver changes phase exactly once before it wakes the parent.

Field phase

pub phase: silk/scheduler.ResponsePublished | silk/scheduler.ResponseRejected | silk/scheduler.ResponseWaiting

The current publication decision.

ResponseWaiting

pub struct ResponseWaiting

A publication decision has not been made yet.

ResponsePublished

pub struct ResponsePublished

The Scheduler accepted the prepared child for publication.

ResponseRejected

pub struct ResponseRejected

The Scheduler rejected and destroyed the prepared child without activation.

NoRequest

pub struct NoRequest

A parent task has no pending publication request.

PendingRequest

pub struct PendingRequest

A parent is parked until the Scheduler processes one publication request.

Field wake

pub wake: Intrinsic.Wake

The Wake consumed after the publication response has been stored.

TaskMailbox

pub struct TaskMailbox

The parent-facing mailbox for one child publication request.

Field request

pub request: silk/scheduler.NoRequest | silk/scheduler.PendingRequest

The request currently visible to the Scheduler driver.

Field response

pub response: silk/shared.Shared<silk/scheduler.PublicationResponse>

The response cell written before the request Wake is consumed.

NoSubmission

pub struct NoSubmission

A submission slot contains no prepared child.

PendingSubmission

pub struct PendingSubmission

A submission slot owns one complete prepared child.

Field task

pub task: PreparedTask

The prepared task moved into the slot before the parent parks.

SubmissionSlot

pub struct SubmissionSlot

The child-task payload paired with one parent mailbox request.

Field phase

pub phase: silk/scheduler.NoSubmission | silk/scheduler.PendingSubmission

The currently installed child submission.

PreparedTask

pub struct PreparedTask

A complete unpublished task prepared by one Scheduler provider.

Details

The Scheduler driver may insert this data into its private task store or destroy it unchanged. The Execution remains Initial until successful publication calls Execution.notifyInitial.

Field identity

pub identity: TaskId

The reserved identity of the child.

Field parent

pub parent: TaskId

The identity of the structured parent.

Field execution

pub execution: Intrinsic.Execution<()>

The unpublished child Execution.

Field canceller

pub canceller: Fiber.CompletionCanceller

The type-erased endpoint used if the task is cancelled.

Field mailbox

pub mailbox: silk/shared.Shared<silk/scheduler.TaskMailbox>

The child's own publication-request mailbox.

Field submission

pub submission: silk/shared.Shared<silk/scheduler.SubmissionSlot>

The child's own publication-submission slot.

PendingPublication

pub struct PendingPublication<A, E>

A prepared child Fiber and the canonical data required for atomic publication.

Details

Fiber.forkChild moves task into parentSubmission, installs a Wake in parentMailbox, and parks until response reports acceptance or rejection. No executable value crosses the service boundary.

Field fiber

pub fiber: silk/fiber.Fiber<A, E>

The affine result handle returned only after successful publication.

Field parentMailbox

pub parentMailbox: silk/shared.Shared<silk/scheduler.TaskMailbox>

The mailbox owned by the parent task.

Field parentSubmission

pub parentSubmission: silk/shared.Shared<silk/scheduler.SubmissionSlot>

The submission slot owned by the parent task.

Field response

pub response: silk/shared.Shared<silk/scheduler.PublicationResponse>

The response observed after the parent resumes.

Field task

pub task: PreparedTask

The complete unpublished child task.

pending

pub fn pending<A, E>(fiber: silk/fiber.Fiber<A, E>, parentMailbox: silk/shared.Shared<silk/scheduler.TaskMailbox>, parentSubmission: silk/shared.Shared<silk/scheduler.SubmissionSlot>, response: silk/shared.Shared<silk/scheduler.PublicationResponse>, task: PreparedTask) -> silk/scheduler.PendingPublication<A, E>

Creates one canonical pending publication from its prepared data.

When to use

Use this provider operation after all child task storage and endpoints have been prepared.

Details

The parent mailbox, submission slot, and response must belong to the calling task. The prepared task remains unpublished and must not have received initial readiness.

Scheduler

pub service Scheduler

A mutable service that prepares one child task for later atomic publication.

Details

Each task receives a distinct owned provider. prepare ends its exclusive provider access before the caller registers the returned publication data and parks for the response.

Operation prepare

effect fn prepare<A, E>(child: once Effect<A ! E ? &mut silk/scheduler.Scheduler>) -> silk/scheduler.PendingPublication<A, E> ! OutOfMemoryError | TaskIdExhaustedError ? &mut Scheduler

Prepares one lazy child task and returns its affine publication value.

Details

The child can require only its owned Scheduler provider. Preparation reserves all child endpoints and one task identity before it returns. It does not activate the child.

prepare

pub effect fn prepare<A, E>(child: once Effect<A ! E ? &mut silk/scheduler.Scheduler>) -> silk/scheduler.PendingPublication<A, E> ! OutOfMemoryError | TaskIdExhaustedError ? &mut Scheduler

Prepares one lazy child task through the active Scheduler provider.

Details

This operation only prepares the task. Fiber.forkChild registers the returned data after the service call ends, then obtains the affine Fiber only after the Scheduler accepts the child.

On this page