Ejemplo n.º 1
0
        private ConcurrentReaderWorkItemQueue BuildCacheReaders()
        {
            var queue = new ConcurrentReaderWorkItemQueue();

            for (int i = 0; i < _maxReadThreads; i++)
            {
                var stream = new UnmanagedMemoryStream(_cachedData, _cachedDataLength);
                var reader = new BinaryReader(stream);
                queue.Enqueue(new ReaderWorkItem(stream, reader, isMemory: true));
            }
            return(queue);
        }
Ejemplo n.º 2
0
        public void CacheInMemory()
        {
            if (_cached || _selfdestructin54321)
            {
                return;
            }

            var sw = Stopwatch.StartNew();

            BuildCacheArray();
            _destructedMemStreams = 0;
            _memoryStreams        = BuildCacheReaders();
            if (_writerWorkItem != null)
            {
                _writerWorkItem.UnmanagedMemoryStream =
                    new UnmanagedMemoryStream(_cachedData, _cachedDataLength, _cachedDataLength, FileAccess.ReadWrite);
            }
            _cached = true;

            _midpoints = null;

            Log.Trace("CACHED TFChunk #{0} at {1} in {2}.", _chunkHeader.ChunkStartNumber, Path.GetFileName(_filename), sw.Elapsed);
        }
Ejemplo n.º 3
0
 private ConcurrentReaderWorkItemQueue BuildCacheReaders()
 {
     var queue = new ConcurrentReaderWorkItemQueue();
     for (int i = 0; i < _maxReadThreads; i++)
     {
         var stream = new UnmanagedMemoryStream(_cachedData, _cachedDataLength);
         var reader = new BinaryReader(stream);
         queue.Enqueue(new ReaderWorkItem(stream, reader, true));
     }
     return queue;
 }
Ejemplo n.º 4
0
        public void CacheInMemory()
        {
            if (_cached || _selfdestructin54321)
                return;
            var sw = Stopwatch.StartNew();

            BuildCacheArray();
            _destructedMemStreams = 0;
            _memoryStreams = BuildCacheReaders();
            if (_writerWorkItem != null)
            {
                _writerWorkItem.UnmanagedMemoryStream = new UnmanagedMemoryStream(_cachedData,
                                                                                  _cachedDataLength,
                                                                                  _cachedDataLength,
                                                                                  FileAccess.ReadWrite);
            }
            _cached = true;

            _midpoints = null;

            Log.Trace("CACHED TFChunk #{0} at {1} in {2}.", _chunkHeader.ChunkStartNumber, Path.GetFileName(_filename), sw.Elapsed);
        }