StashExtension

portals.api.builder.TaskExtensions$.StashExtension$

Attributes

Experimental
true
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Extensions

Extensions

extension (t: TaskBuilder)(t: TaskBuilder)
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)
   }
 }
}