3 ms·
Swift Actors need some improvement. For example, how could Swift Actors implement the following: TrainController ≡ moving := False /
by ProfHewitt 5y ago
Swift Actors need some improvement.
For example, how could Swift Actors implement the following:
TrainController ≡
moving := False // train is initially not moving
isOpen := False // door is initially closed
open ↦ moving ?? // Received request to open door, there are two cases for moving:
False ↠ // Case moving=False, then
isOpen := True; // then set isOpen to True and then
DoorController.open // send door an open request in hole of the region
True ↠ Throw TrainMoving[] // Case moving=True, then throw TrainMoving
close ↦ Hole DoorController.close ; // Received request to close door, so send door a close request
// in a hole of the region and after door reports that it is closed,
isOpen := False // set isOpen to False
move ↦ isOpen ?? // Received request to move train, there are two cases for isOpen:
False ↠ // Case isOpen=False, then
moving := True; // set moving to True and then
EngineController.move // send engine a move request in a hole of the region
True ↠ Throw DoorOpen[ ] // Case isOpen=True, then throw DoorOpen
stop ↦ Hole EngineController.stop ; // Received request to stop train, so send engine a stop
// request in a hole of the region and after engine reports that it is stopped,
moving := False // set moving to False