Sha256: 4d715772f70f0f3a524a4e0bc80a70eb6b8fb08cdb845b722d24aabd74742161

Contents?: true

Size: 326 Bytes

Versions: 8

Compression:

Stored size: 326 Bytes

Contents

#!/usr/bin/env ruby

$LOAD_PATH.push File.expand_path("../../lib", __FILE__)
require "celluloid/autostart"

module Enumerable
  # Simple parallel map using Celluloid::Futures
  def pmap(&block)
    futures = map { |elem| Celluloid::Future.new(elem, &block) }
    futures.map(&:value)
  end
end

p 100.times.pmap { |n| n * 2 }

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
celluloid-0.17.4 examples/simple_pmap.rb
celluloid-0.18.0.pre examples/simple_pmap.rb
celluloid-0.17.3 examples/simple_pmap.rb
celluloid-0.17.2 examples/simple_pmap.rb
celluloid-0.17.1.2 examples/simple_pmap.rb
celluloid-0.17.1.1 examples/simple_pmap.rb
celluloid-0.17.1 examples/simple_pmap.rb
celluloid-0.17.0 examples/simple_pmap.rb