TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

EventMachine: scalable non-blocking i/o in ruby

82 点作者 tmm1大约 15 年前

6 条评论

davidw大约 15 年前
This is what's frustrating about being a Tcl fan: Tcl had this something like 15 years ago, because it was necessary for Tk. "Tcl don't get no respect" :-/<p>That said, though, what separates the "men from the Erlangs" is that in Tcl, Ruby, Python, Javascript, and company, "never block the reactor" is the name of the game, you can't do a while { 1 } { something } in your event handler or it will wedge the whole thing.<p>In Erlang, thanks to its built in scheduler, you can.
评论 #1193924 未加载
评论 #1194088 未加载
评论 #1194031 未加载
评论 #1193913 未加载
评论 #1194061 未加载
tptacek大约 15 年前
As luck would have it, I'm sitting here writing a fuzzer for a trading protocol in EventMachine as we speak.<p>Ruby and async network programming go together like gin and vermouth. It's one of the reasons I'm so happy with Ruby's block/lambda support, and so irritated with Python's: many of the basic programming idioms for evented network code have direct support in the Ruby language.<p>I've done a fair bit of Twisted Python programming in the past, and I find EventMachine to be far more intuitive and flexible. On the other hand, EventMachine will crash on me once in a blue moon, and it swallows exceptions, which is extremely frustrating. They're both great packages.<p>The big problem that still needs solving for EventMachine is evented adapters for an ORM (any ORM). You've always been able to talk to MySQL over an evented socket, but that's clumsy compared to DataMapper.<p>I am still totally not sold that Ruby threads are tenable, so a lot of the "advanced" stuff in EventMachine does nothing for me. It's great even without it.
评论 #1193946 未加载
donw大约 15 年前
I recently had a chance to play around with EventMachine, as I wanted to set up an event-based scheduler within my application.<p>I was not impressed.<p>If you try and mix 'EventMachine' and 'other threadsafe code', it seems to fall down pretty hard. In my case, it would run anything executed via next_tick, but would refuse to run any timers... unless I defined a periodic timer in the main event loop, after which timers started working... but only every time the periodic timer executed.<p>I dug through the code to see if I could fix the problem, and gave up after trying to figure out why they seem to implement timers in two different ways, and it doesn't seem very threadsafe (next_tick is, but none of the timer code looks to be).<p>EM also expects that your entire application will run inside the EventMachine loop; there's no way to ask EM for a Reactor that you can then hand events.<p>If you're not running threaded code, then EM will probably work just fine; the Thin webserver looks to be a really nice Rack deployment option if you're on MRI.<p>If you need to mix EM up with anything else running on the same VM, look elsewhere.
aantix大约 15 年前
Take a look at Juggernaut. It's an event server based on EventMachine that provides nice integration with Rails. Streams events to the client via Flash.
filterfish大约 15 年前
Excellent preso. If you are interested in eventmachine or just getting into it read this.
macournoyer_大约 15 年前
Great presentation! Some exciting new stuff in Eventmachine.