bhuga/promising-future — pull request #7 by michaeljbishop (2012-10-12 17:40:21+00:00)
Title: Enable thread pooling

Hi Ben,

I have one last change for consideration. This one is bigger as it changes the API, but hopefully, you'll appreciate what it brings to the table.

The new functionality is within a new method:

Promising::promise_with_worker
------------------------------

This method returns both a promise and a Proc (the worker). In this way, the consumer of the API can write their own thread pool, and make a pooled future by calling this method and adding the worker to the thread pool's queue while returning the corresponding promise.

Here's a sample implementation:

class ThreadPool
def future(*args,&block)
promise,worker = Promising::promise_with_worker(*args,&block)
add_to_queue worker
promise
end
end

In this branch, the API changes are:

- The Future class is wholly replaced by a smaller 'Promising::future()' method.
- The Kernel module extension is renamed to a module named 'Promising'. I did this to reduce conflicts with code that used the previous api.

Thanks again for this library.