VARIABLES queue1, queue2, tempVar, state
...
Queue1 == INSTANCE InnerQueue WITH Values <- Message, q <- queue1
Queue2 == INSTANCE InnerQueue WITH Values <- Message, q <- queue2
...
FetchMessage ==
/\ ~Queue1!IsEmpty
/\ state = "Idle"
/\ Queue1!Pop(tempVar)
/\ state' = "Processing"
/\ UNCHANGED <<...>> \* other variables unchanged
ProcessMessage ==
/\ state = "Processing"
/\ \* Do the processing
/\ state' = "Finished"
/\ UNCHANGED <<>> \* other variables unchanged
Finish==
/\ state = "Finished"
/\ Queue2!Push(tempVar)
/\ state' = "Idle"
/\ UNCHANGED <<>> \* other variables unchanged
Actions ==
\/ FetchMessage
\/ ProcessMessage
\/ Finish