Ejemplo n.º 1
0
//  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:
	}
}
Ejemplo n.º 2
0
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)
	}

}
Ejemplo n.º 3
0
// ForceSnapshot forces a snapshot rather than requesting one.
func (bh *BufferHist) ForceSnapshot(buff buffer.Buffer, mc cursor.MultiCursor) {
	bh.snapshot(buff.Dup(), mc.Dup())
}