public ProtoSharded(int maxBlocks) { for (var i = 0; i < _lruCache.Length; i++) { _lruCache[i] = new ProtoLRUCache(maxBlocks / 16, _cache); } _completionPort = CreateIoCompletionPort((IntPtr)(-1), IntPtr.Zero, UIntPtr.Zero, (uint)_threads.Length); if (_completionPort.IsInvalid) { var error = Marshal.GetLastWin32Error(); throw new FileLoadException($"Unable to create a completion port with code {error}"); } for (var i = 0; i < _threads.Length; i++) { var thread = new System.Threading.Thread(IOThreadLoop); thread.IsBackground = true; thread.Start(); _threads[i] = thread; } }
internal static extern bool GetQueuedCompletionStatus(CompletionPortSafeHandle completionPort, out uint lpNumberOfBytesTransferred, out UIntPtr lpCompletionKey, out IntPtr lpOverlapped, int dwMilliseconds);