Since 0.12.8, we've had over 130 patches with numerous bug fixes, improvements
and several new features. Highlights include:
- Improved Performance
- subclasses of EM::Connection are not created unless necessary
- prevent unnecessary system calls to epoll_ctl/kevent
- the reactor uses numeric signatures instead of strings,
resulting in a ~15% overall performance boost
- API Changes
- EM.reactor_thread accessor for the reactor's thread
- EM.next_tick and EM.schedule are now thread-safe
- EM::connect will raise a more better EM::ConnectionError with details
- EM.epoll=/kqueue= will raise EM::Unsupported when unavailable
- improved the cryptic "no timer" exception and increased the
default limit to 10k timers
- bugfix and improved performance for EM.current_time
- EM.add_periodic_timer returns PeriodicTimer object
- EM::Connection#get_sock_opt wrapper for getsockopt()
- added EM.watch for notifications about file descriptors
for notify_read/writable events, you cannot use EM.attach
EM.watch(fd, Watcher){ |c| c.notify_readable = true }
- EM::Connection#pending_connect_timeout= setter (defaults to 20s)
- EM.bind_connect can bind to random source port using nil
EM.bind_connect('local.ip', nil, 'remote.ip', 1234)
- added EM::Connection#pause/resume/paused? to pause and resume I/O
- EM::Connection#proxy_incoming_to takes an optional buffer size for
limiting RAM usage when dealing with slow clients
- Protocol Additions
- allow overriding the serializer used for ObjectProtocol
- basic SOCKS v4 client protocol implementation
- Platform Support
AIX, OpenBSD, Solaris
- minor fixes to support these platforms
Windows
- fix missing unbind events on refused outbound connections
- fix issues with ruby 1.9 on windows
- Ruby Support
JRuby
- major overhaul of the jruby reactor for better compat and performance
- basic EM.attach/watch support on the Sun JVM
- fully compatible with JRuby 1.4
Ruby 1.9
- fix bugs trying to kill the EM.defer threadpool
- fix signal handling to catch ctrl+c and other signals gracefully
Rubinius
- minor changes to build a compatible C extension
Special thanks to the following people for making this release possible:
- Bernd Ahlers
- Chris Turner
- Dan Mayer
- Perry Smith
- Bill 'spatulasnout' Kelly
- Hemant 'gnufied' Kumar
- Jake 'yakischloba' Douglas
- James 'raggi' Tucker
- coderrr
The rdoc has been updated and is available at http://eventmachine.rubyforge.org
Aman
Nice. Thanks for keeping up with all that shtuff.
-r
C:\Documents and Settings\Administrator\code>gem which eventmachine
(checking gem eventmachine-0.12.10-x86-mswin32-60 for eventmachine)
c:/ruby/lib/ruby/gems/1.8/gems/eventmachine-0.12.10-x86-mswin32-60/lib/eventmachine.rb
C:\Documents and Settings\Administrator\code>ruby testserver.rb
-- someone connected to the echo server!
Processing [0]
-- someone disconnected from the echo server!
Processing [1]
Processing [2]
-- someone connected to the echo server!
Processing [0]
-- someone disconnected from the echo server!
Processing [3]
Processing [1]
Processing [4]
Processing [2]
Processing [5]
Processing [3]
Processing [6]
Processing [4]
Processing [7]
Processing [5]
Processing [8]
Processing [6]
Processing [9]
Processing [7]
Done with last count is [9]...
Processing [8]
Processing [9]
Done with last count is [9]...
To pass in arguments to your handlers, simply:
module Client
def initialize(one, two)
end
end
EM.connect 'host', 1234, Client, 'one', 2
Aman
On Sat, Oct 31, 2009 at 7:24 PM, Levent <levent...@gmail.com> wrote:
> 12.8 worked fine, similar to 8.1
> Below are the simple client and server code.
> After starting the server, invoke the client twice. You'll see two
> simultaneous bacground outputs from the deferred jobs on the server
> side with 12.8
> With 12.10, however, the second request does not go through.
>
> By the way, I'm relatively a rookie in Ruby and new to eventmachine
> and I would appreciate if you could help me figure out how I can pass
> a parameter into the modules used by EM:start_server or EM:connect.
> For example in the example below, I want to pass 'myvar' into the
> Client instead of $input so that I can loop through and create
> multiple connections to multiple machines each passing different type
> of data.
> I looked thru FAQ and snippet, but did not see a simple example
> illustrating that usage.
>
> Thanks,
> Levent
>
> ------------------
>
> require 'rubygems'
> require 'eventmachine'
>
> module Client
> def post_init
> send_data $input
> @data = ""
> end
>
> def receive_data data
> @data = data
> if @data
> puts "RECEIVED" + @data
> puts "Now we'll terminate the loop, which will also close the
> connection"
> EventMachine::stop_event_loop
> end
> end
>
> def unbind
> puts "A connection has terminated"
> end
> end
>
> $input = 'mydata'
>
> # myvar = 'myvalue'
> EventMachine::run {
> EventMachine::connect "127.0.0.1", 8081,Client
> }
> puts "The event loop has ended"
>
>
> -------------
>
> require 'rubygems'
> require 'eventmachine'
>
> module EchoServer
>
> def run_rats
> i = 0
> 10.times do |i|
> puts "Processing [#{i}] "
> sleep 1
> end
> "last count is [#{i}]..."
> end
>
> def post_init
> puts "-- someone connected to the echo server!"
> end
>
> def receive_data data
> send_data ">>>you sent: #{data}"
> operation = proc {
> run_rats
> }
> callback = proc {|result|
> puts 'Done with ' + result
> }
> EventMachine.defer( operation, callback )
>
> end
>
> def unbind
> puts "-- someone disconnected from the echo server!"
> end
> end
>
> EventMachine::run {
> EventMachine::start_server "127.0.0.1", 8081, EchoServer
> }
> puts 'Finished server'