tarcieri/nio4r — pull request #16 by loganb (2013-02-09 23:38:13+00:00)
Title: Factor locking into Ruby-only code for both Pure and Libev

Hello,

I've started to break up my big refactor into smaller pieces so that I can address the issues you mentioned as I go and make them more reasonable to review and accept.

This pull request adds some basic sanity tests around thread-safety (libev & pure only) and then factors the locking into pure ruby code. The C code, for example, was emulating a Monitor using a Mutex, and this code simply uses a reentrant Monitor. My goal here in a later patch is to make threadsafety optional in single-threaded applications.

NOTE: Part of this factoring moves the implementations of Selector into different modules (NIO::Pure::Selector and NIO::Libev::Selector). I intend to further leverage this later in a future patch where the @selectables hash is factored.