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 TaskIdA 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: u64The provider-local monotonic identity value.
Implementation Copy for TaskId
impl Copy for TaskIdImplementation HashKey for TaskId
impl HashKey for TaskIdOperation equals
equals = TaskId.taskIdEqualsOperation hash
hash = TaskId.taskIdHashTaskIdExhaustedError
pub struct TaskIdExhaustedErrorA typed failure that reports exhaustion of the task identity space.
PublicationResponse
pub struct PublicationResponseA 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.ResponseWaitingThe current publication decision.
ResponseWaiting
pub struct ResponseWaitingA publication decision has not been made yet.
ResponsePublished
pub struct ResponsePublishedThe Scheduler accepted the prepared child for publication.
ResponseRejected
pub struct ResponseRejectedThe Scheduler rejected and destroyed the prepared child without activation.
NoRequest
pub struct NoRequestA parent task has no pending publication request.
PendingRequest
pub struct PendingRequestA parent is parked until the Scheduler processes one publication request.
Field wake
pub wake: Intrinsic.WakeThe Wake consumed after the publication response has been stored.
TaskMailbox
pub struct TaskMailboxThe parent-facing mailbox for one child publication request.
Field request
pub request: silk/scheduler.NoRequest | silk/scheduler.PendingRequestThe 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 NoSubmissionA submission slot contains no prepared child.
PendingSubmission
pub struct PendingSubmissionA submission slot owns one complete prepared child.
Field task
pub task: PreparedTaskThe prepared task moved into the slot before the parent parks.
SubmissionSlot
pub struct SubmissionSlotThe child-task payload paired with one parent mailbox request.
Field phase
pub phase: silk/scheduler.NoSubmission | silk/scheduler.PendingSubmissionThe currently installed child submission.
PreparedTask
pub struct PreparedTaskA 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: TaskIdThe reserved identity of the child.
Field parent
pub parent: TaskIdThe identity of the structured parent.
Field execution
pub execution: Intrinsic.Execution<()>The unpublished child Execution.
Field canceller
pub canceller: Fiber.CompletionCancellerThe 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: PreparedTaskThe 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 SchedulerA 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 SchedulerPrepares 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 SchedulerPrepares 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.