// DMA ring concept (pseudo)
class DMARing {
constructor(n){ this.desc = Array(n).fill(null); this.head = 0; this.tail = 0; }
post(buffer){ this.desc[this.tail] = buffer; this.tail = (this.tail+1)%this.desc.length; }
complete(){ const b = this.desc[this.head]; this.desc[this.head]=null; this.head=(this.head+1)%this.desc.length; return b; }
}