Created
April 14, 2017 18:05
-
-
Save neektza/45bac5e0e09254578f1bb89b1c04bf37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module EventMachine | |
def self.run_deferred_callbacks | |
until (@resultqueue ||= []).empty? | |
result,cback = @resultqueue.pop | |
cback.call result if cback | |
end | |
size = @next_tick_mutex.synchronize { @next_tick_queue.size } | |
size.times do |i| | |
callback = @next_tick_mutex.synchronize { @next_tick_queue.shift } | |
begin | |
callback.call | |
ensure | |
EM.next_tick {} if $! | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment