Search⌘ K
AI Features

Expecting Different Types of Messages

Explore handling different message types in D's message passing concurrency using receive and receiveTimeout functions. Understand how message dispatching to handlers works with types and how to avoid blocking with timeouts.

receive()

receiveOnly() can expect only one type of message. receive(), on the other hand, can wait for more than one type of message. It dispatches messages to message handling delegates. When a message arrives, it is compared to the message type of each delegate. The delegate that matches the type of the particular message handles it. For example, the following receive() call specifies two message handlers that handle messages of types ...