Skip to content
This repository
branch: master


Build Status Code Climate

ifuture is a Futures gem for Ruby that use processes forking rather than threads. This allows parallelism with MRI without the GIL blocking as it might with threads. ifuture is implemented with ichannel for interprocess communication over a Unix socket or Redis. Run your code in another process and get the result back later!

The Future starts running right away, but isn't blocking because it runs in its own forked process and uses ichannel to communicate with the parent process. If the value is asked for and it is ready, it will be returned right away. If the value is asked for early, the Future blocks until delivery.


gem install ifuture

The Redis gem is required as well if you opt to use Redis instead of the default Unix socket transporter.

gem install redis


require 'ifuture'
future = IFuture.unix Marshal do
  sleep 2
  'result back from the child process!'

future.ready? #=> false
sleep 2
future.ready? #=> true
future.value #=> "result back from the child process!"

Code Serialization Format

The default serialization format is Marshal, but you can use JSON, YAML or other formats that implement the methods #load and #dump.

require 'ifuture'
require 'json'
future = IFuture.unix JSON do
  sleep 2
  {ok: true}
future.value #=> {"ok"=>true}

IPC Transporter

By default ifuture uses ichannel with unix sockets for transferring serialized code. An alternate choice is to use ichannel with Redis, locally or over the network.

require 'ifuture'
future = IFuture.redis Marshal, {host: 'localhost', key: 'readme'} do
  sleep 5
future.value #=> 42


  1. Fork it
  2. Commit your changes
  3. Create a pull request
  4. :cake:
Something went wrong with that request. Please try again.