Project

probject

0.0
No commit activity in last 3 years
No release in over 3 years
A lightweight actor-based concurrent object framework with each object running in it's own process
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 5.0.1
 Project Readme

Description

A lightweight actor-based concurrent object framework with each object running in it's own process.

How does it work?

When a new object is created, it will fork and open up two UNIX sockets, one for requests and one for responses. Each method invocation on the actor is asynchronous, but one can optionally wait for the method to return by reading from the response channel, using a future.

To do asyncrhonous invocations, use .async or .tell

probject.async.my_method # => nil

To do asyncrhonous invocations that return a future, use .future or .ask

probject.future.my_method # => Probject::Future

To do syncrhonous invocations, just call the method as you normally would

probject.my_method # => whatever my_method returns

Example

This example is not very practical, but it illustrates how Probject can be used.

require 'net/http'
require 'probject'

class GoogleRequester < Probject::Actor

  def do_request
    @response = Net::HTTP.get('www.google.com', '/')
  end

  def response_length
    @response.length
  end
end

probjects = []

1.upto 5 do |i|
  probjects[i] = GoogleRequester.new

  probjects[i].async.do_request
end

1.upto 5 do |i|
  # do a synchronous request - will block until all previous requests have been handled
  puts probjects[i].response_length
  # could also be written as probjects[i].future.response_length.get
end

Install

$ gem install probject

Platform support

This gem is written for MRI, where forking is the best way of implementing concurrenent applications, and real threading is not supported. If you use Rubinius or JRuby I would propose looking in to Celluloid.

Windows does not work for two reasons - no UNIX sockets and no forking implemented in Ruby.

supported

  • MRI (1.9+) on *NIX

License

Released under the MIT License. See LICENSE.txt.