bbuf_basei = class implements bbuf slot arr:aint, size, cnt, ipt, opt:int new = method(n:int) replies(bbuf{empty}) return(bbuf$[arr:aint!new(n), size:n, cnt:0, ipt:0, opt:0]!{empty}) end new put = method({empty,mid}b:bbuf{mid,full}, val:int) b.ipt := (b.ipt+1) // b.size; b.cnt := b.cnt + 1 b.arr[b.ipt] := val if b.cnt = b.size then b!{full} else b!{mid} end end put get = method({full,mid}b:bbuf{mid,empty}) replies(int) b.opt := (b.opt + 1) // b.size; b.cnt := b.cnt - 1 v:int := b.arr[b.opt] if b.c = 0 then b!{empty} else b!{mid} end return(v) end get end bbuf_basei