plt/racket — pull request #501 by tonyg (2013-11-27 12:18:31+00:00)
Title: Fix bug: timer-manager used global state, but could be multiply instantiated

The timer manager depends on timer-ch, a global singleton. If `start-timer-manager` is called more than once, such as when multiple servers are run listening on separate ports within a single racket process, multiple threads will read from timer-ch, leading to interleaving of requests (!) and subsequent confusion and failure.

There are two possibilities that spring to mind:
- make timer-ch non-global. Hard, but the right thing.
- make the timer-manager thread global. Easy, and a bit dirty, but mostly harmless in that a single timer-manager thread can do the job of multiple threads, more or less.

This patch goes for the easy option, and makes it so that in any given system, no more than one timer-manager thread will ever be started, to match the (unchanged) singleton nature of timer-ch.