You might take a look at Celluloid:

http://celluloid.io/


On Wed, Feb 13, 2013 at 7:50 PM, Abhijit Sarkar <lists / ruby-forum.com>wrote:

> Hi,
> I started on Ruby less than a week ago but have already come to
> appreciate the power of the language. I am trying my hands on a classic
> producer-consumer problem, implemented as an Orange tree (c.f.
> http://pine.fm/LearnToProgram/?Chapter=09). The Orange tree grows each
> year until it dies and produces a random number of Oranges each year
> (Producer). Oranges can be picked as long there are any on the tree
> (Consumer).
>
> I've got two problems here:
>
> 1) The attached code gives me the following exception:
> /Users/Abhijit/Workspace/eclipse/ruby/learn_to_program/orange_tree.rb:84:
> warning: instance variable @orange_tree not initialized
> /Users/Abhijit/Workspace/eclipse/ruby/learn_to_program/orange_tree.rb:84:in
> `<class:Worker>': undefined method `age' for nil:NilClass
> (NoMethodError)
>   from
> /Users/Abhijit/Workspace/eclipse/ruby/learn_to_program/orange_tree.rb:45:in
> `<main>'
>
> 2) I am not sure that the multithreading part is correctly coded.
>
> Any help is very much appreciated. I've got myself a couple of books,
> including "Programming Ruby" and "The Ruby Programming Language" but
> none of them contain a true "producer-consumer problem".
>
> Attachments:
> http://www.ruby-forum.com/attachment/8127/orange_tree.rb
>
>
> --
> Posted via http://www.ruby-forum.com/.
>
>


-- 
Tony Arcieri