I don’t post code on here nearly as often as I should. Here’s some code I just finished for a future RubyTapas episode. It implements a thread-safe, optionally bounded, timeout-enabled queue class suitable for communication between threads. Please throw rocks at it and tell me what I got wrong. It’s a Gist, so feel free to submit alternatives via forks.
EDIT: Eric Hodel has pointed out one issue already, via Twitter: I’d forgotten to signal @space_available after popping an item off of the queue!