yasmin.concurrence module
- class yasmin.concurrence.Concurrence(states: Dict[str, State], default_outcome: str, outcome_map: Dict[str, Dict[State, str]] = {})
Bases:
State
Runs a series of states in parallel
The Concurrence class runs a set of states concurrently, waiting for the termination of each, and then returns a single output according to a provided rule map, or a default outcome if no rule is satisfied.
- Attributes:
_states (Dict[str, State]): The states to run concurrently (name -> state). _default_outcome (str): Default outcome. _outcome_map (Dict[str, Dict[str, str]]): Specifies which combination of state outputs should produce a given
overall output.
_intermediate_outcomes (Dict[str, Optional[str]]): Stores the intermediate outcomes of the concurrent states. _mutex (Lock): Mutex for intermediate outcome map.
- cancel_state() None
Cancels the current state execution.
This method sets the canceled flag to true and logs the action.
- execute(blackboard: Blackboard) str
Executes the state’s specific logic.
- Args:
blackboard (Blackboard): A shared pointer to the Blackboard to use during execution.
- Returns:
str: A string representing the outcome of the execution.
- execute_and_save_state(state: State, state_name: str, blackboard: Blackboard) None
Executes a state and saves its outcome to the intermediate map.
- Args:
state (State): A state to execute. state_name (str): The name of the state to execute. blackboard (Blackboard): An instance of Blackboard that provides the context for execution.
- get_default_outcome() str
Returns the default outcome for this concurrence state.
- Returns:
str: The default outcome as a string.
- get_outcome_map() Dict[str, Dict[str, str]]
Returns the outcome map for this concurrence state.
- Returns:
Dict[str, Dict[str, str]]: A map of outcome names to their requirements.