Forum Discussion
EnTerr
10 years agoRoku Guru
"tar" wrote:
temporary solved it next waymyVar = m.global.someImportantField
while myVar = invalid
' do not spam render thread (m.global owner) with requests, but try at least 10 times per second '
sleep(100)
' usually works from the first try '
myVar = m.global.someImportantField
end while
You can generalize it a little, like so (typing this on the fly, not tested):
function get_node_field(node as Object, fieldName as String):
' sample use: get_node_field(m.global, "someImportantField") '
res = invalid
while res = invalid:
res = node.getField(fieldName)
end while
return res
end function
Beware that there is no way to account for a field that actually has its value set to invalid. If that's the case, the function gets infinitely loopy. I thought for a moment i can use .hasField() to check - but nope, that one would also fail on a "dreadlock" and return False (in other words it returning False means either there is no such field or... there is such field but a timeout occured). Congrats @RokuCo - that was some sleight-of-hand throw into the halting problem :mrgreen:
PS. don't forget to write also write_node_field() counterpart, since setting a field may also fail silently due to lock timeout
PPS. i see no need to sleep() since the rendezvous in my understanding already takes care of that, presumably it does not spin in a tight loop.