redding/dat-tcp — pull request #6 by jcredding (2013-02-07 22:12:45+00:00)
Title: Stop spinning threads up for every connection

This changes DatTCP to be more efficient and not spin a thread up
for every connection. Instead it will spin up threads (to a
maximum) and leave them going to continue processing connections.
This is more efficient and keeps us from continually creating
threads. This, plus removing any 'serving' logging (even null
logging), made the server faster and smoother.

* The `WorkerPool` no longer 'processes' connections. It adds
them to it's queue and signals any workers who are waiting.
* Workers are spawned and, if no connections are queued up, they
become idle waiting. Once a connection is added, they will
pick it up and serve it.
* If a connection is added and no worker is available to pick it
up, then a new one will be spawned if the pool hasn't reached
it's maximum allowed.
* Shutting down a pool will allow any connections that have been
picked up by a worker to finish processing. Connections on the
queue will not be served.

@kellyredding - This implements proper management of threads with the `WorkerPool`. Based on what the internet says, creating threads is expensive, so I think this is a better practice than our previous implementation. This is heavily borrowed from puma.

The overall speed is a bit misleading, because a large portion of it was due to removing logging and getting the connection's socket address. There is about a 0.3ms time shaved off the average request, about 0.2ms is due to the removal of the logging. About 0.1ms was gained from the thread management changes.