Пример #1
0
func copyReferences(clientReferences *capn.DataList, references *msgs.VarIdPos_List, referencesInNeedOfPositions *[]*msgs.VarIdPos) {
	for idx, l := 0, clientReferences.Len(); idx < l; idx++ {
		vUUIdPos := references.At(idx)
		vUUId := clientReferences.At(idx)
		vUUIdPos.SetId(vUUId)
		*referencesInNeedOfPositions = append(*referencesInNeedOfPositions, &vUUIdPos)
	}
}
Пример #2
0
func (c *cache) updateFromWrite(txnId *common.TxnId, vUUId *common.VarUUId, value []byte, refs *capn.DataList) bool {
	vr, found := c.m[*vUUId]
	references := make([]*common.VarUUId, refs.Len())
	switch {
	case found && vr.version.Equal(txnId):
		log.Fatal("Divergence discovered on update of ", vUUId, ": server thinks we don't have ", txnId, " but we do!")
		return false
	case found:
		// Must use the new array because there could be txns in
		// progress that still have pointers to the old array.
		vr.references = references
	default:
		vr = &valueRef{references: references}
		c.m[*vUUId] = vr
	}
	// fmt.Printf("%v updated (%v -> %v)\n", vUUId, vr.version, txnId)
	vr.version = txnId
	vr.value = value
	for idz, n := 0, refs.Len(); idz < n; idz++ {
		vr.references[idz] = common.MakeVarUUId(refs.At(idz))
	}
	return found
}