grosser/parallel — pull request #79 by yaoguai (2013-09-26 02:19:12+00:00)
Title: Only attempt multiprocessing if Process.fork is available

Two changes here. The first and most significant is that Parallel only attempts multiprocessing if forking is available in the Ruby implementation. Some platforms such as Windows do not implement fork, and this can be detected directly. For example, on the Windows port of Ruby:

Process.respond_to?(:fork)
=> false

As for what to do in such a situation, I think "work_direct" and a warning message to $stderr would be the simplest and most non-intrusive way to deal with it.

There was also a point in the code in which the process count was calculated when it didn't need to be, and that interfered with the logic in Parallel.map. A better approach is just to leave the process count as nil until we arrive at Parallel.map, and then that code can handle the logic of deciding how many processes, and if it's feasible to use multiprocessing.