public ValueListImpl Get(KeyImpl key) { Object o; if (!locks.TryGetValue(key, out o)) { throw new KeyNotFoundException <KeyImpl>(key); } lock (o) { AllocRecord record = dict[key]; byte[] data = appleStore.Read(record.position, record.size); ValueListImpl values = serializer.FromByteArray(data); return(values); } }
public void Insert(KeyImpl key, ValueListImpl values) { Object o = new Object(); if (!locks.TryAdd(key, o)) { throw new KeyAlreadyPresentException <KeyImpl>(key); } lock (o) { byte[] data = serializer.ToByteArray(values); appleStore.Write(nextFree, data); dict[key] = new AllocRecord(nextFree, data.Length); nextFree += data.Length; return; } }