add tryReadUntil and make fixes along the way
Summary:
this diff adds tryReadUntil, which is a mirror of tryWriteUntil in both function and implementation.
Two bugs were exposed in the process of implementing and testing tryWriteUntil; they are fixed as well and are as follows:
1. tryObtainPromisedPopTicket didn't assign to the passed ticket return reference in the failure case
2. TurnSequencer::tryWaitForTurn() didn't distinguish between past turns and timeouts in the failure case; they need to be
differentiated because SingleElementQueue::tryWaitFor{De/En}queue() should only fail in the timeout case, not if the turn has passed.
The two added unit tests are admittedly clumsy, but making the obvious simplifications to them keeps them from triggering the premature timeout race caused by bug 2 above, so I kept them as is.
Reviewed By: magedm
Differential Revision:
D4050515
fbshipit-source-id:
b0a3dd894d502c44be62d362ea347a1837df4c2f