Skip to content

Instantly share code, notes, and snippets.

@meltingice
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meltingice/d06c3457341b6f0f8f03 to your computer and use it in GitHub Desktop.
Save meltingice/d06c3457341b6f0f8f03 to your computer and use it in GitHub Desktop.
module Async
def async(method)
prepend(Module.new {
define_method(method) do |*args|
Thread.new(*args) do |*args|
puts Thread.current.object_id.to_s(16)
super(*args)
end
end
})
method
end
end
class Example
extend Async
async def background_method
puts "I am in a separate thread!"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment