// Snapshot places a snapshot request onto the snapshot queue. func (bh *BufferHist) Snapshot(buff buffer.Buffer, mc cursor.MultiCursor) { request := BufferState{ buff: buff.Dup(), mc: mc.Dup(), } bh.reqMutex.Lock() bh.snapReq = request bh.reqMutex.Unlock() select { case bh.snapChan <- struct{}{}: default: } }
func TestMakeBuffer(t *testing.T) { var buff buffer.Buffer buff = buffer.MakeBuffer([]string{""}) if buff.Length() != 1 { t.Error("MakeBuffer is wrong:", buff) } buff = buffer.MakeBuffer([]string{"", "", "hello", ""}) if buff.Length() != 4 { t.Error("MakeBuffer is wrong:", buff) } if buff.GetRow(2).Length() != 5 { t.Error("MakeBuffer is wrong:", buff) } }
// ForceSnapshot forces a snapshot rather than requesting one. func (bh *BufferHist) ForceSnapshot(buff buffer.Buffer, mc cursor.MultiCursor) { bh.snapshot(buff.Dup(), mc.Dup()) }