Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
Make ::next_tick actually thread-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 committed Oct 5, 2009
1 parent 9053357 commit 7bd3315
Showing 1 changed file with 5 additions and 27 deletions.
32 changes: 5 additions & 27 deletions lib/eventmachine.rb
Expand Up @@ -1044,26 +1044,13 @@ def self.run_deferred_callbacks # :nodoc:
cback.call result if cback
end

@next_tick_queue ||= []
if (l = @next_tick_queue.length) > 0
l.times {|i| @next_tick_queue[i].call}
@next_tick_queue.slice!( 0...l )
end

=begin
(@next_tick_queue ||= []).length.times {
cback=@next_tick_queue.pop and cback.call
}
=end
=begin
if (@next_tick_queue ||= []) and @next_tick_queue.length > 0
ary = @next_tick_queue.dup
@next_tick_queue.clear
until ary.empty?
cback=ary.pop and cback.call
@next_tick_mutex.synchronize do
@next_tick_queue ||= []
if (l = @next_tick_queue.length) > 0
l.times {|i| @next_tick_queue[i].call}
@next_tick_queue.slice!( 0...l )
end
end
=end
end


Expand Down Expand Up @@ -1165,15 +1152,6 @@ def self.next_tick pr=nil, &block
(@next_tick_queue ||= []) << ( pr || block )
signal_loopbreak if reactor_running?
end
=begin
(@next_tick_procs ||= []) << (pr || block)
if @next_tick_procs.length == 1
add_timer(0) {
@next_tick_procs.each {|t| t.call}
@next_tick_procs.clear
}
end
=end
end

# A wrapper over the setuid system call. Particularly useful when opening a network
Expand Down

0 comments on commit 7bd3315

Please sign in to comment.