Project

em-wrapper

0.0
No commit activity in last 3 years
No release in over 3 years
Wraps objects callbacks to EventMachine next ticks, so allows transparent multiplexing of objects which aren't multiplexable by default.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.0.0
>= 1.5.2
>= 0.12.3

Runtime

 Project Readme

EventMachine Wrapper

em-wrapper wraps objects callbacks to EventMachine next ticks using EM::next_tick, so allows transparent multiplexing of objects which aren't multiplexable by default.

It provides proxied class, so returned class is kind of the same class as wrapped class, with different #object_id only. Also standard returns work as expected and as is usuall.

See some example:

require "em-wrapper"
require "eventmachine"

class Foo
    def foo
        yield :foo
        return :bar
    end
end

wrapped = EM::Wrapper::new(Foo)::new
EM::run do
    p wrapped.foo { |value|      # 1. will print :bar out
        p value                  # 2. will be run in next EM 
                                 #    tick, will print :foo out
    }
end    

Also object wrapping is supported. In that case, simply give object instance instead of class object to the constructor. Wrapped object instance will be returned.

Copyright

Copyright © 2011 – 2015 Martin Poljak. See LICENSE.txt for further details.