Exemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="_segmentId"></param>
 /// <returns></returns>
 // Can be used to pre-load handles, e.g., after a checkpoint
 protected SafeFileHandle GetOrAddHandle(int _segmentId)
 {
     if (logHandles.TryGetValue(_segmentId, out SafeFileHandle h))
     {
         return(h);
     }
     return(logHandles.GetOrAdd(_segmentId, segmentId => CreateHandle(segmentId)));
 }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="_segmentId"></param>
        /// <returns></returns>
        // Can be used to pre-load handles, e.g., after a checkpoint
        protected SafeFileHandle GetOrAddHandle(int _segmentId)
        {
            if (logHandles.TryGetValue(_segmentId, out SafeFileHandle h))
            {
                return(h);
            }
            if (_disposed)
            {
                return(null);
            }
            var result = logHandles.GetOrAdd(_segmentId, segmentId => CreateHandle(segmentId));

            if (_disposed)
            {
                foreach (var logHandle in logHandles.Values)
                {
                    logHandle.Dispose();
                }
                return(null);
            }
            return(result);
        }