I have a function whose interface I cannot change, which is stuck in an infinite loop receiving messages from another module. The method called for receiving stuff can be blocking for a potentially infinite amount of time.
I have thought of simply using a done
channel for forcing this loop to break in the case it receives anything from said channel, but this method only works if the other operations are listening from channels too. Is there a way to do this the message-passing way?
func ReceiveMessages() {
for true {
switch buffer := ms.Receive().(type) { // The Receive operation can block
case Reply:
// Do stuff
case []byte:
// Do other stuff
}
}
}