Skip to content

Instantly share code, notes, and snippets.

@vangberg
Created August 27, 2009 14:03
Show Gist options
  • Save vangberg/176296 to your computer and use it in GitHub Desktop.
Save vangberg/176296 to your computer and use it in GitHub Desktop.
def session_initiated
set("foo", "bar") {}
# @queue: [Proc{}]
set("lol", "cat") {}
# @queue: [Proc{}]
read "/foo/bar.mp3" do |result|
..
end
# @queue: [Proc{..}, Proc{update_session}]
end
# Now, the block supplied to read() is called at the fourth response.
def session_initiated
set "foo", "bar"
# @queue: []
set "lol", "cat"
# @queue: []
read "/foo/bar.mp3" do |result|
..
end
# @queue: [Proc{..}, Proc{update_session}]
end
# Now, both set(), set() and read() generates a response, which will
# call queue_pop. So the block supplied to read() will be called after
# the second response, which is the response to set(). This results in
# the block being called with *no* parameters–and too early–and thus a
# *foo called with wrong paramenters (0 for 1)* or something like that.
# Makes sense?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment