Example #1
0
 public static IMemoryOwner <T> Slice <T>(this IMemoryOwner <T> that, int offset, int length)
 {
     if (!(that is CountdownMemoryOwner <T>))
     {
         // other types of IMemoryOwner may return Memory instance to pool and give it to other side for use
         throw new InvalidOperationException(
                   $"Passed memory owner type '{that.GetType().FullName}' isn't supported.");
     }
     // wrap it with another countdown to support slicing
     return(that.AsCountdown(offset, length));
 }