Permalink
Browse files

unless to if

  • Loading branch information...
1 parent 665cde8 commit df8b3584fa417f5f7908e5840deb022f81311285 fonzo14 committed Aug 30, 2011
Showing with 10 additions and 10 deletions.
  1. +10 −10 lib/em-jack/connection.rb
View
20 lib/em-jack/connection.rb
@@ -219,7 +219,15 @@ def put(msg, opts = nil, &blk)
end
def each_job(timeout = nil, &blk)
- unless @fiberized
+ if (@fiberized)
@jherdman
jherdman Aug 30, 2011

Ah, thank you! unless and then else always gives me the willies. The brackets around @fiberized, however, does too.

@dj2
dj2 Aug 30, 2011

patches accepted, heh.

+ work = Proc.new do
+ Fiber.new do
+ job = reserve(timeout)
+ blk.call(job)
+ end.resume
+ EM.next_tick { work.call }
+ end
+ else
work = Proc.new do
r = reserve(timeout)
r.callback do |job|
@@ -230,15 +238,7 @@ def each_job(timeout = nil, &blk)
EM.next_tick { work.call }
end
end
- else
- work = Proc.new do
- Fiber.new do
- job = reserve(timeout)
- blk.call(job)
- end.resume
- EM.next_tick { work.call }
- end
- end
+ end
work.call
end

0 comments on commit df8b358

Please sign in to comment.