Esempio 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:
	}
}
Esempio n. 2
0
func (bh *BufferHist) snapshot(buff buffer.Buffer, mc cursor.MultiCursor) {

	curBuf, curMC := bh.Current()
	curRow := curMC.GetRow(0)
	newRow := mc.GetRow(0)
	if curRow-newRow > 5 || newRow-curRow > 5 {
		state := NewBufferState(curBuf, mc)
		bh.elemMutex.Lock()
		bh.element = bh.list.InsertAfter(state, bh.element)
		bh.elemMutex.Unlock()
	}

	state := NewBufferState(buff, mc)
	bh.elemMutex.Lock()
	bh.element = bh.list.InsertAfter(state, bh.element)
	bh.elemMutex.Unlock()

	bh.trim()

}
Esempio 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())
}