You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
state.State - main component, must be implemented as runtime-function
state.Bool - little helper that wraps State and implements boolean routing
state.Accumulator - this one needs to be moved from builtin/streams.neva (and should be imported from there), it's used by Reduce (in the future it will be moved to streams.Reduce)
// State maintains the value of type T.
// It waits for message from `init` and `get`, then sends initial value to `res`.
// After that loop starts - wait for `set` and `get`, send latest value to `res`, repeat.
// It only receives `init` once, subsequent messages to that port will be blocked.
#extern(state)
pub def State<T>(init T, set T, get T) (res T)
// Bool is a helper-component for routing based on a boolean state.
// It wraps `State<bool>` and has the same semantics except conditional output.
pub def Bool(init bool, set bool, get bool) (then bool, else bool) {
state State<bool>
---
:init -> state:init
:set -> state:set
:get -> state:get
state:res -> switch {
true -> :then
_ -> :else
}
}
// Accumulator maintains the current state of the reduction.
// It updates its value with each new input and outputs the final result when last is true.
#extern(accumulator)
pub def Accumulator<T>(init T, upd T, last bool) (cur T, res T)
The text was updated successfully, but these errors were encountered:
Implement
state
package with 3 public components:state.State
- main component, must be implemented as runtime-functionstate.Bool
- little helper that wraps State and implements boolean routingstate.Accumulator
- this one needs to be moved frombuiltin/streams.neva
(and should be imported from there), it's used byReduce
(in the future it will be moved tostreams.Reduce
)The text was updated successfully, but these errors were encountered: