Skip to content

Instantly share code, notes, and snippets.

@egwspiti
Created June 17, 2015 22:52
Show Gist options
  • Save egwspiti/6adaac61230cc2607eb3 to your computer and use it in GitHub Desktop.
Save egwspiti/6adaac61230cc2607eb3 to your computer and use it in GitHub Desktop.
class X
attr_accessor :a
end
x = X.new
f = Thread.new do
sleep 2
x.a = "boom"
end
def wait_ready(obj, property, timeout)
(0..timeout).each do |i|
print '.'
break if obj.send(property)
sleep 1
end
puts
end
puts "variable a is #{x.a}"
wait_ready(x, :a, 10)
puts "variable a is #{x.a}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment