Elm Exactly

Rule 185p-proc-sleep

TransitionsK→⟨ℓ⟩K′K\step{\opt{\ell}}K'
P(pid)=(tk,s′,o)tk→atk′a=sleep(v′)⇓tk′′if v′∈Fltfin then s≥s′+max⁡(0,v′)(s,v,M,P,sb,Q,H)→a(s,v,M,P+{pid↦(tk′,s,o)},sb,Q,H)\frac{\begin{array}{c}P(\pid)=(\tk,s',\pgorig)\premsep\tk\effred{\effa}\tk'\premsep \effa=\effdone{\effsleep(v')}{\tk''}\\ \text{if}\ v'\in\effFltFin\ \text{then}\ s\geq s'+\max(0,v')\end{array}}{\begin{array}{c}(s,v,M,P,\sbv,Q,H)\step{\effa} (s,v,M,P+\{\pid\mapsto(\tk',s,\pgorig)\},\sbv,Q,H)\end{array}}
(185)
Read it in its chapter·Permanent address: /standard/rules/p-proc-sleep

Comments

The process reached prim(sleep,v′)\effprim(\effsleep,v') by its step at time s′s', so the action takes place no sooner than max⁡(0,v′)\max(0,v') milliseconds later; for an infinite or NaN delay, no condition is imposed. The definition sets no time by which the action must take place.

Referred to from

  • The comment on rule p-wait (Chapter 9)
TeX source
\defnrule[r:p-proc-sleep]
  {P(\pid)=(\tk,s',\pgorig)\premsep\tk\effred{\effa}\tk'\premsep
   \effa=\effdone{\effsleep(v')}{\tk''}\\
   \text{if}\ v'\in\effFltFin\ \text{then}\ s\geq s'+\max(0,v')}
  {(s,v,M,P,\sbv,Q,H)\step{\effa}
   (s,v,M,P+\{\pid\mapsto(\tk',s,\pgorig)\},\sbv,Q,H)}

Tests (8)

  • elm / MinimalSleepTest
    A process sleeps, and time passes.
  • elm / OutgoingPortTuple3KeepsRunningTest
    A program that sends a 3-tuple through an outgoing port keeps running afterwards.
  • elm-core / ProcessPrimitiveOutcomeTest
    The primitive tasks `Process.sleep`, `Process.spawn` and `Process.kill` succeed with their outcomes.
  • elm-core / ProcessSpawnKillHalfTest
    A process killed with `Process.kill` before its sleep finishes never runs the rest of its task, while the processes left alive do.
  • elm-core / ProcessSpawnRecursiveTest
    A process spawned with `Process.spawn` can itself spawn a process, nested five deep, and every level runs.
  • elm-core / ProcessYieldThrashingTest
    Two processes that each repeatedly yield with `Process.sleep 0` both run to completion.
  • elm-core / StandardA81SleepBeyond32BitsTest
    `Process.sleep d` waits at least `d` milliseconds, also when `d` is above 2^31 - 1.
  • elm-core / TimerEffectTest
    A `Platform.worker` that chains `Process.sleep` timers through `Task.perform` receives each timer message in turn and stops after five.

Discussions

Discuss this rule·Search the discussions on GitHub

Discussions are on GitHub; one about this rule has [r:p-proc-sleep] in its title.

A Standard Definition of Elm? (Draft version 0.4) © Rupert Smith. The text is licensed under CC BY 4.0: share and adapt it freely, with credit and a link to the licence.