Prefer microtask to timeout in write queue

This seems to make little difference but it's more correct as we want
to write as fast as possible to minimize input latency
This commit is contained in:
Daniel Imms
2022-09-24 16:27:56 -07:00
parent c6e4788344
commit 0b8120808c
+2 -2
View File
@@ -105,7 +105,7 @@ export class WriteBuffer {
// schedule chunk processing for next event loop run
if (!this._writeBuffer.length) {
this._bufferOffset = 0;
setTimeout(() => this._innerWrite());
queueMicrotask(() => this._innerWrite());
}
this._pendingData += data.length;
@@ -217,7 +217,7 @@ export class WriteBuffer {
this._callbacks = this._callbacks.slice(this._bufferOffset);
this._bufferOffset = 0;
}
setTimeout(() => this._innerWrite());
queueMicrotask(() => this._innerWrite());
} else {
this._writeBuffer.length = 0;
this._callbacks.length = 0;