Class: Quark::MdkUtil::WaitForPromise
Overview
Utility to blockingly wait for a Promise to get a value.
Constant Summary
DatawireQuarkCore::Static::Unassigned
Class Method Summary
collapse
Instance Method Summary
collapse
_lazy_statics, static, unlazy_statics
#to_s
Constructor Details
Returns a new instance of WaitForPromise.
23
24
25
26
27
|
# File 'lib/mdk_util.rb', line 23
def initialize()
self.__init_fields__
nil
end
|
Class Method Details
.wait(p, timeout, description) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/mdk_util.rb', line 42
def self.wait(p, timeout, description)
snapshot = p.value()
if (snapshot.hasValue())
return snapshot.getValue()
end
done = ::DatawireQuarkCore::Condition.new()
waiter = ::Quark.mdk_util.WaitForPromise.new()
p.andThen(::Quark.quark._BoundMethod.new(waiter, "_finished", ::DatawireQuarkCore::List.new([done])))
msTimeout = ((timeout) * (1000.0)).round()
done.acquire()
done.waitWakeup(msTimeout)
done.release()
snapshot = p.value()
if (!(snapshot.hasValue()))
raise (("Timeout waiting for ") + (description))
end
return snapshot.getValue()
nil
end
|
Instance Method Details
#__init_fields__ ⇒ Object
85
86
87
88
89
|
# File 'lib/mdk_util.rb', line 85
def __init_fields__()
nil
end
|
#_finished(value, done) ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'lib/mdk_util.rb', line 32
def _finished(value, done)
done.acquire()
done.wakeup()
done.release()
return true
nil
end
|
#_getClass ⇒ Object
64
65
66
67
68
69
|
# File 'lib/mdk_util.rb', line 64
def _getClass()
return "mdk_util.WaitForPromise"
nil
end
|
#_getField(name) ⇒ Object
71
72
73
74
75
76
|
# File 'lib/mdk_util.rb', line 71
def _getField(name)
return nil
nil
end
|
#_setField(name, value) ⇒ Object
78
79
80
81
82
83
|
# File 'lib/mdk_util.rb', line 78
def _setField(name, value)
nil
nil
end
|