puma/puma — pull request #111 by kenkeiter (2012-06-28 00:42:49+00:00)
Title: Unobtrusively modify Server#run to optionally execute in Thread#current.

(Sorry for the double pull-request. Something odd going on with my machine.)

This patch unobtrusively fixes Server#run so that it can be executed in the main thread. This is primarily to allow users to wrap run in whatever thread spawning mechanism they'd like to, and enables use with Celluloid by including the Celluloid module at load time,

```ruby
Puma::Server.send(:include, Celluloid)
```

allowing supervision of the server's runloop. Note that it does NOT change the way run needs to be called, but simply allows it to be called with an additional hash arg :in_thread => false, which will start the event loop in the calling thread. For example:

```ruby
server = Puma::Server.new(App)
server.add_tcp_listener('localhost', 9090)
server.run(:in_thread => false) # starts runloop in Thread#current, returning nothing.
```

It may also be started the old way, with no modification:

```ruby
server.run
```