feat: add AppendableUploadWriteableByteChannel#flush()#3261
feat: add AppendableUploadWriteableByteChannel#flush()#3261BenWhitehead merged 1 commit intomainfrom
Conversation
Allows blocking the invoking thread until the number of bytes acknowledged by GCS matches the number of written bytes prior to calling flush().
e843eaa to
12484ef
Compare
|
|
||
| @Override | ||
| public void awaitAck(long writeOffset) throws InterruptedException { | ||
| lock.lock(); |
There was a problem hiding this comment.
question: why are we using lock here?
There was a problem hiding this comment.
The Condition confirmedBytesUpdated is tied to the lock instance.
Conditions (also known as condition queues or condition variables) provide a means for one thread to suspend execution (to "wait") until notified by another thread that some state condition may now be true. Because access to this shared state information occurs in different threads, it must be protected, so a lock of some form is associated with the condition. The key property that waiting for a condition provides is that it atomically releases the associated lock and suspends the current thread, just like Object.wait. [1]
When we await the condition on line 903, the lock will automatically be released while the invoking thread waits for the call of await to return.
- [1]
Conditionjavadocs
Allows blocking the invoking thread until the number of bytes acknowledged by GCS matches the number of written bytes prior to calling flush().