Exemple #1
0
        /// <inheritdoc />
        public override bool ConcurrentWriter(ref Key key, ref SpanByte src, ref SpanByte dst)
        {
            if (locking)
            {
                dst.SpinLock();
            }

            // We can write the source (src) data to the existing destination (dst) in-place,
            // only if there is sufficient space
            if (dst.Length < src.Length || dst.IsMarkedReadOnly())
            {
                dst.MarkReadOnly();
                if (locking)
                {
                    dst.Unlock();
                }
                return(false);
            }

            // Option 1: write the source data, leaving the destination size unchanged. You will need
            // to mange the actual space used by the value if you stop here.
            src.CopyTo(ref dst);

            // We can adjust the length header on the serialized log, if we wish.
            // This method will also zero out the extra space to retain log scan correctness.
            dst.ShrinkSerializedLength(src.Length);

            if (locking)
            {
                dst.Unlock();
            }
            return(true);
        }
Exemple #2
0
 /// <inheritdoc />
 public override void Lock(ref RecordInfo recordInfo, ref SpanByte key, ref SpanByte value, LockType lockType, ref long lockContext)
 {
     value.SpinLock();
 }
 /// <inheritdoc />
 public override void ConcurrentReader(ref SpanByte key, ref SpanByte input, ref SpanByte value, ref byte[] dst)
 {
     value.SpinLock();
     dst = value.ToByteArray();
     value.Unlock();
 }