Sha256: 588c03ee6ce419f788b154eccbb16818b95ff19a24f4f0f1cd0e39d7f5e6dcd4

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

# PbActor

Process based Actor.

## Installation

Add this line to your application's Gemfile:

    gem 'pb_actor'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install pb_actor

## Usage

```ruby
require 'pb_actor'
require 'benchmark'

class Test
  include PbActor
  def fib(n)
    if n < 2
      1
    else
      fib(n - 1) + fib(n - 2)
    end
  end

  def p_fib(n)
    puts fib(n)
  end
end

t = Test.new
#=> <PbActor::Proxy:0x00000002106448 @origin=#<Test:0x00000002106470>, @pid=23487, @rd=#<IO:fd 7>, @wr=#<IO:fd 10>>

t.alive?
#=> true

t.fib(30)
#=> 1346269

t.async.p_fib(30)
#=> nil
# 1346269

t.terminate
t.alive?
#=> false

def fib n
  if n < 2
    1
  else
    fib(n - 1) + fib(n - 2)
  end
end

Benchmark.bm do |bm|
  bm.report{puts (30..35).map{|n| fib(n)}.reduce(:+)}
  bm.report{puts (30..35).map{|n| Test.new.future.fib(n)}.map(&:value).reduce(:+)}
end
#=> Try it youself!
```

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pb_actor-0.0.5 README.md
pb_actor-0.0.4 README.md
pb_actor-0.0.3 README.md
pb_actor-0.0.2 README.md