def stash[T, U](f: TaskStash[T, U] => GenericTask[T, U, Nothing, Nothing]): GenericTask[T, U, Nothing, Nothing]
Behavior factory to build a task that can stash messages, and unstash them later.
Behavior factory to build a task that can stash messages, and unstash them later.
Attributes
See also
portals.examples.distributed.actor.ActorRuntime for example of use.
Note
Can only be used from an internal context with an instance of TaskContextImpl.
Example
InitTask { ctx =>
given TaskContextImpl[Int, Int, _, _] = ctx
TaskBuilder.stash { stash =>
// Stash messages
TaskBuilder.processor[Int, Int] { event =>
// example, stash all events until we receive a 0, then unstash all
if event == 0 then stash.unstashAll()
else stash.stash(event)
}
}
}