case class PiState(inputs: Map[Chan, Input], outputs: Map[Chan, Output], calls: List[PiFuture], threads: Map[Int, PiFuture], threadCtr: Int, freshCtr: Int, processes: Map[String, PiProcess], resources: ChanMap) extends Product with Serializable
This is the pi-calculus state of a running workflow.
We separate inputs from outputs to make searching for matching channels more efficient. We could have everything in one list like PiLib does.
- inputs
a map of Input type continuations based on their primary channels
- outputs
a map of Output type continuations based on their primary channels
- calls
a list of processes that have been called but the inputs haven't arrived yet
- threads
a map of processes that have been called and whose results we want. The calls to the actual processes should happen outside the PiState by a process executor, so that things are kept clean and independent here. Each call has a unique reference number so that results don't clash.
- threadCtr
an integer to help create unique reference numbers for threads
- freshCtr
an integer to help create unique (fresh) channel names
- processes
a map of available processes, both atomic and composite, so that we know how to handle calls when they occur
- resources
a ChanMap of unhandled resources. We try to keep this as clean as possible, so that it only contains resources that need to be received by a pending call (though this is not guaranteed, we might get some leftover garbage in here as well).
- Alphabetic
- By Inheritance
- PiState
- Serializable
- Serializable
- Product
- Equals
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
PiState(inputs: Map[Chan, Input], outputs: Map[Chan, Output], calls: List[PiFuture], threads: Map[Int, PiFuture], threadCtr: Int, freshCtr: Int, processes: Map[String, PiProcess], resources: ChanMap)
- inputs
a map of Input type continuations based on their primary channels
- outputs
a map of Output type continuations based on their primary channels
- calls
a list of processes that have been called but the inputs haven't arrived yet
- threads
a map of processes that have been called and whose results we want. The calls to the actual processes should happen outside the PiState by a process executor, so that things are kept clean and independent here. Each call has a unique reference number so that results don't clash.
- threadCtr
an integer to help create unique reference numbers for threads
- freshCtr
an integer to help create unique (fresh) channel names
- processes
a map of available processes, both atomic and composite, so that we know how to handle calls when they occur
- resources
a ChanMap of unhandled resources. We try to keep this as clean as possible, so that it only contains resources that need to be received by a pending call (though this is not guaranteed, we might get some leftover garbage in here as well).
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- def ->[B](y: B): (PiState, B)
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
- val calls: List[PiFuture]
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
- def ensuring(cond: (PiState) ⇒ Boolean, msg: ⇒ Any): PiState
- def ensuring(cond: (PiState) ⇒ Boolean): PiState
- def ensuring(cond: Boolean, msg: ⇒ Any): PiState
- def ensuring(cond: Boolean): PiState
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
execute(p: PiFuture): Option[PiState]
This converts a PiFuture in the calls list to an instatiated thread to be executed externally.
This converts a PiFuture in the calls list to an instatiated thread to be executed externally. A unique thread id is generated using threadCtr. We also remove the mappings of all free channels in the process inputs from the resources list. These get used up in the process execution and are no longer needed. This helps keep the resources list clean.
-
def
executeFirst(): Option[PiState]
By 'execute' we mean converting a call to a thread.
By 'execute' we mean converting a call to a thread. This means checking a process in the calls list about whether its inputs have arrived. This executes the first process (if any) in calls whose inputs have arrived.
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
- def formatted(fmtstr: String): String
- val freshCtr: Int
-
final
def
fullReduce(): PiState
Perform all possible reductions to the state.
Perform all possible reductions to the state.
- Annotations
- @tailrec()
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
handleCall(c: PiCall): PiState
Handles process calls.
Handles process calls. For atomic process calls, we create an instantiated PiFuture and add it to the calls. We also generate and add the process input terms. For composite process calls we instantiate the body and add it as a term.
-
def
handleThreads(handler: ((Int, PiFuture)) ⇒ Boolean): PiState
Executes a thread handling function over all threads.
Executes a thread handling function over all threads. Handler is expected to have side-effects (typically some Future trigger). Handler should return true if a thread was handled successfully, false if it failed. Returns the updated state containing only threads that were handled successfully.
- def incFCtr(i: Int = 1): PiState
- def incTCtr(): PiState
- val inputs: Map[Chan, Input]
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- val outputs: Map[Chan, Output]
- val processes: Map[String, PiProcess]
-
def
reduce(): Option[PiState]
Performs either a single pi-calculus reduction or else handles the first available call with completed inputs.
Performs either a single pi-calculus reduction or else handles the first available call with completed inputs. The intersection of key sets detects common channels between inputs and outputs, which can then communicate.
- def removeThread(ref: Int): PiState
- def removeThreads(refs: Iterable[Int]): PiState
- val resources: ChanMap
-
def
result(ref: Int, res: PiObject): Option[PiState]
This method should be used by the external executor to report the result of an executed thread and obtain the appropriate new state.
This method should be used by the external executor to report the result of an executed thread and obtain the appropriate new state. The PiFuture is removed from the threads list and its output Term is added, with the given object as the output resource.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
- val threadCtr: Int
- val threads: Map[Int, PiFuture]
- def updateProcs(f: (PiProcess) ⇒ PiProcess): PiState
- def updateProcs(m: Map[String, PiProcess]): PiState
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
- def withCalls(l: PiFuture*): PiState
- def withFCtr(i: Int): PiState
- def withProc(p: PiProcess): PiState
- def withProcs(l: PiProcess*): PiState
- def withSub(c: Chan, a: PiObject): PiState
- def withSubs(m: ChanMap): PiState
- def withSubs(l: Seq[(Chan, PiObject)]): PiState
- def withSubs(m: Map[Chan, PiObject]): PiState
- def withTCtr(i: Int): PiState
-
def
withTerm(t: Term): PiState
Introducing a term can have many different effects on the state.
Introducing a term can have many different effects on the state. e.g. an Input term is simply added to the inputs, but a PiCut term adds new terms to both inputs and outputs and it affects freshCtr. We also want to leave enough room for any future types of terms we might want to add. We therefore defer the state effect to be determined by the Term itself.
- def withTerms(t: Seq[Term]): PiState
- def withThread(ref: Int, name: String, chan: Chan, args: Seq[PiResource]): PiState
- def withThreads(t: (Int, PiFuture)*): PiState
- def →[B](y: B): (PiState, B)