select, context & mutex

Waiting on several channels at once

A live-tracking handler waits on more than one thing: a new GPS fix on one channel, or a signal that the walk ended on another, or a timeout so it never hangs forever. select is a switch for channel operations β€” it blocks until one of its cases can proceed, then runs that one.

If several cases are ready, select picks one at random. A default case (optional) runs immediately when nothing else is ready, so you can poll without blocking.