示例#1
0
        public async virtual ValueTask <MemorySegment> MemoryAtIndexAsync(int i)
        {
            if (MemoryChunks == null)
            {
                MemoryChunks = MemoryBlocksLoadingInfo.Select(x => (MemoryChunk)null).ToList();
            }
            if (MemoryChunks[i] == null)
            {
                await LoadMemoryAtIndexAsync(i);
            }
            var chunk = MemoryChunks[i];

            return(new MemorySegment(chunk, new MemoryBlockSlice(0, chunk.Length)));
        }
示例#2
0
        public virtual MemorySegment MemoryAtIndex(int i)
        {
            if (MemoryChunks == null)
            {
                MemoryChunks = MemoryBlocksLoadingInfo.Select(x => (MemoryChunk)null).ToList();
            }
            if (MemoryChunks[i] == null)
            {
                LoadMemoryAtIndex(i);
            }
            var chunk = MemoryChunks[i];

            return(new MemorySegment(chunk, new MemoryBlockSlice(0, chunk.Length)));
        }
示例#3
0
 public virtual void AppendMemoryChunk(MemoryChunk memoryChunk)
 {
     if (MemoryBlocksLoadingInfo == null)
     {
         MemoryBlocksLoadingInfo = new List <MemoryBlockLoadingInfo>();
     }
     if (MemoryChunksIndexFromID == null)
     {
         MemoryChunksIndexFromID = new Dictionary <int, int>();
     }
     MemoryBlocksLoadingInfo.Add(memoryChunk.LoadingInfo);
     MemoryChunksIndexFromID[memoryChunk.MemoryBlockID] = MemoryBlocksLoadingInfo.Count() - 1;
     MemoryChunks.Add(memoryChunk);
     if (memoryChunk.MemoryBlockID > MaxMemoryBlockID)
     {
         MaxMemoryBlockID = memoryChunk.MemoryBlockID;
     }
     Length += (long)memoryChunk.Length;
 }