Closed matklad closed 2 years ago
For what it's worth, my opinion is that the addition of this API is a much better idea than making get
block and #92 should not be merged.
Ironically, I need this now for http://github.com/near/nearcore/ :D
Hm, it's interesting that this is slightly not-trivial. Today, when a thread does get_or_try_init
and fails (ie, it does not actually initialize the cell), it wakes all other waiters. This makes sense, as every waiter can set the cell.
With wait
, we'll get waiters which ideally should not be woken up if we know that the cell is uninint.
This seems plausible:
The implementaiton should basically stuff the current thread into the waiters list, without attempting to set the value.