public unsafe void Callback(IAsyncResult result)
            {
                if (errorCode == 0)
                {
                    try
                    {
                        logHandle.EndRead(result);
                        fixed(void *source = memory.buffer)
                        {
                            Buffer.MemoryCopy(source, (void *)destinationAddress, readLength, readLength);
                        }
                    }
                    catch (IOException e)
                    {
                        errorCode = (uint)(e.HResult & 0x0000FFFF);
                    }
                    catch
                    {
                        // Non-IO exception; assign error code of max value
                        errorCode = uint.MaxValue;
                    }
                }

                memory.Return();
                Overlapped ov = new Overlapped(0, 0, IntPtr.Zero, asyncResult);

                callback(errorCode, 0, ov.UnsafePack(callback, IntPtr.Zero));
            }
            public unsafe void Callback(IAsyncResult result)
            {
                memory.Return();
                Overlapped ov = new Overlapped(0, 0, IntPtr.Zero, asyncResult);

                callback(0, 0, ov.UnsafePack(callback, IntPtr.Zero));
            }
            public unsafe void Callback(IAsyncResult result)
            {
                fixed(void *source = memory.buffer)
                {
                    Buffer.MemoryCopy(source, (void *)destinationAddress, readLength, readLength);
                }

                memory.Return();
                Overlapped ov = new Overlapped(0, 0, IntPtr.Zero, asyncResult);

                callback(0, 0, ov.UnsafePack(callback, IntPtr.Zero));
            }
Esempio n. 4
0
        public void Free()
        {
            if (freeBuffer1.buffer != null)
            {
                freeBuffer1.Return();
            }

            if (handle != null)
            {
                handle.Signal();
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Free
        /// </summary>
        public void Free()
        {
            if (freeBuffer1 != null)
            {
                freeBuffer1.Return();
                freeBuffer1 = null;
            }

            if (freeBuffer2 != null)
            {
                freeBuffer2.Return();
                freeBuffer2 = null;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Free
        /// </summary>
        public void Free()
        {
            if (freeBuffer1.buffer != null)
            {
                freeBuffer1.Return();
                freeBuffer1.buffer = null;
            }

            if (freeBuffer2.buffer != null)
            {
                freeBuffer2.Return();
                freeBuffer2.buffer = null;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Free
        /// </summary>
        public void Free()
        {
            if (freeBuffer1 != null)
            {
                freeBuffer1.Return();
                freeBuffer1 = null;
            }
            if (freeBuffer2 != null)
            {
                freeBuffer2.Return();
                freeBuffer2 = null;
            }

            completedSemaphore?.Release();
        }
Esempio n. 8
0
        /// <summary>
        /// Free
        /// </summary>
        public void Free()
        {
            if (freeBuffer1 != null)
            {
                freeBuffer1.Return();
                freeBuffer1 = null;
            }
            if (freeBuffer2 != null)
            {
                freeBuffer2.Return();
                freeBuffer2 = null;
            }

            flushCompletionTracker?.CompleteFlush();
        }
Esempio n. 9
0
 /// <summary>
 /// Free
 /// </summary>
 public void Free()
 {
     if (freeBuffer1 != null)
     {
         freeBuffer1.Return();
         freeBuffer1 = null;
     }
     if (freeBuffer2 != null)
     {
         freeBuffer2.Return();
         freeBuffer2 = null;
     }
     if (handle != null)
     {
         handle.Signal();
     }
 }
            public unsafe void Callback(IAsyncResult result)
            {
                uint errorCode = 0;

                try
                {
                    logHandle.EndWrite(result);
                }
                catch
                {
                    errorCode = 1;
                }

                memory.Return();
                Overlapped ov = new Overlapped(0, 0, IntPtr.Zero, asyncResult);

                callback(errorCode, 0, ov.UnsafePack(callback, IntPtr.Zero));
            }
            public unsafe void Callback(IAsyncResult result)
            {
                uint errorCode = 0;

                try
                {
                    logHandle.EndRead(result);
                    fixed(void *source = memory.buffer)
                    {
                        Buffer.MemoryCopy(source, (void *)destinationAddress, readLength, readLength);
                    }
                }
                catch
                {
                    errorCode = 1;
                }

                memory.Return();
                Overlapped ov = new Overlapped(0, 0, IntPtr.Zero, asyncResult);

                callback(errorCode, 0, ov.UnsafePack(callback, IntPtr.Zero));
            }
            public unsafe void Callback(IAsyncResult result)
            {
                if (errorCode == 0)
                {
                    try
                    {
                        logHandle.EndWrite(result);
                    }
                    catch (IOException e)
                    {
                        errorCode = (uint)(e.HResult & 0x0000FFFF);
                    }
                    catch
                    {
                        // Non-IO exception; assign error code of max value
                        errorCode = uint.MaxValue;
                    }
                }

                memory.Return();
                Overlapped ov = new Overlapped(0, 0, IntPtr.Zero, asyncResult);

                callback(errorCode, 0, ov.UnsafePack(callback, IntPtr.Zero));
            }
        /// <summary>
        /// Get next record in iterator
        /// </summary>
        /// <param name="recordInfo"></param>
        /// <returns></returns>
        public unsafe bool GetNext(out RecordInfo recordInfo)
        {
            recordInfo = default;

            while (true)
            {
                currentAddress = nextAddress;

                // Check for boundary conditions
                if (currentAddress >= endAddress)
                {
                    return(false);
                }

                epoch?.Resume();
                var headAddress = hlog.HeadAddress;

                if (currentAddress < hlog.BeginAddress && !forceInMemory)
                {
                    epoch?.Suspend();
                    throw new FasterException("Iterator address is less than log BeginAddress " + hlog.BeginAddress);
                }

                if (frameSize == 0 && currentAddress < headAddress && !forceInMemory)
                {
                    epoch?.Suspend();
                    throw new FasterException("Iterator address is less than log HeadAddress in memory-scan mode");
                }

                var currentPage = currentAddress >> hlog.LogPageSizeBits;
                var offset      = currentAddress & hlog.PageSizeMask;

                if (currentAddress < headAddress && !forceInMemory)
                {
                    BufferAndLoad(currentAddress, currentPage, currentPage % frameSize, headAddress, endAddress);
                }

                long physicalAddress;
                if (currentAddress >= headAddress || forceInMemory)
                {
                    physicalAddress = hlog.GetPhysicalAddress(currentAddress);
                }
                else
                {
                    physicalAddress = frame.GetPhysicalAddress(currentPage % frameSize, offset);
                }

                // Check if record fits on page, if not skip to next page
                var recordSize = hlog.GetRecordSize(physicalAddress).Item2;
                if ((currentAddress & hlog.PageSizeMask) + recordSize > hlog.PageSize)
                {
                    nextAddress = (1 + (currentAddress >> hlog.LogPageSizeBits)) << hlog.LogPageSizeBits;
                    epoch?.Suspend();
                    continue;
                }

                nextAddress = currentAddress + recordSize;

                ref var info = ref hlog.GetInfo(physicalAddress);
                if (info.SkipOnScan || info.IsNull())
                {
                    epoch?.Suspend();
                    continue;
                }

                currentPhysicalAddress = physicalAddress;
                recordInfo             = info;
                if (currentAddress >= headAddress || forceInMemory)
                {
                    memory?.Return();
                    memory = hlog.bufferPool.Get(recordSize);
                    Buffer.MemoryCopy((byte *)currentPhysicalAddress, memory.aligned_pointer, recordSize, recordSize);
                    currentPhysicalAddress = (long)memory.aligned_pointer;
                }
                epoch?.Suspend();
                return(true);
            }
Esempio n. 14
0
 /// <summary>
 /// Dispose
 /// </summary>
 public void Dispose()
 {
     // Do not dispose request_key as it is a shallow copy
     // of the key in pendingContext
     record.Return();
 }
Esempio n. 15
0
 public void Dispose()
 {
     mem.Return();
 }