/**
 * Copyright (c) 2018-present, heineiuo.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */ import { WriteBatch } from "./WriteBatch" ; export class Writer { batch ! : WriteBatch | void ; sync = false ; done = false ; resolve ! : ( ) => void ; signal ( ) { if ( this . resolve ) this . resolve ( ) ; delete this . resolve ; } wait ( ) { delete this . resolve ; return new Promise ( ( resolve ) => ( this . resolve = resolve ) ) ; } } export class WriterQueue { private list : Writer [ ] = [ ] ; public push ( writer ) { this . list . push ( writer ) ; } public front ( ) { return this . list [ 0 ] ; } public popFront ( ) { this . list . shift ( ) ; } get length ( ) : number { return this . list . length ; } * iterator ( start = 0 ) { for ( let i = start ; i < this . list . length ; i ++ ) { yield this . list [ i ] ; } } }