Helper module that enable to manage the local memory state of each thread.
For a sample, see sample/src/Advanced.elm
and its live demo.
Core type to store local memory states.
init : LocalMemory a
Construct an initial instance of LocalMemory
.
toList : LocalMemory a -> List ( Thread.Procedure.ThreadId, a )
Convert into list. The elements in this list are ordered by the time the thread was created, from newest to oldest.
asyncChild : Thread.Lifter.Lifter memory (LocalMemory a) -> a -> Thread.Procedure.Block a event -> Thread.Procedure.Procedure memory event
Run a child Block
in a new thread by Thread.Procedure.async
, assign a local memory for the thread, and free the local memory when the thread is end.
The second argument is initial value of the local memory.
blockChild : Thread.Lifter.Lifter memory (LocalMemory a) -> a -> Thread.Procedure.Block a event -> Thread.Procedure.Procedure memory event
Run a child Block
by Thread.Procedure.block
, assign a local memory for the thread, and free the local memory when the thread is end.
The second argument is initial value of the local memory.
async : Thread.Lifter.Lifter memory (LocalMemory a) -> a -> ((Thread.Procedure.Block a event -> Thread.Procedure.Block memory event) -> Thread.Procedure.Block memory event) -> Thread.Procedure.Procedure memory event
Similar to asyncChild
, but async
can also handle parent Procedure
s in the new thread.
block : Thread.Lifter.Lifter memory (LocalMemory a) -> a -> ((Thread.Procedure.Block a event -> Thread.Procedure.Block memory event) -> Thread.Procedure.Block memory event) -> Thread.Procedure.Procedure memory event
Similar to blockChild
, but block
can also handle parent Procedure
s in the new thread.