File tree Expand file tree Collapse file tree 1 file changed +30
-6
lines changed Expand file tree Collapse file tree 1 file changed +30
-6
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ public class ByteBuffer : IDisposable
34
34
/// more data is available.
35
35
/// </summary>
36
36
private bool endOfFile ;
37
+ private bool disposedValue ;
37
38
38
39
/// <summary>
39
40
/// Initializes a new instance of the <see cref="ByteBuffer"/> class using the default buffer size and limit.
@@ -145,12 +146,6 @@ public int AvailableWritableBytes
145
146
}
146
147
}
147
148
148
- /// <inheritdoc/>
149
- public void Dispose ( )
150
- {
151
- ArrayPool < byte > . Shared . Return ( this . buffer ) ;
152
- }
153
-
154
149
/// <summary>
155
150
/// Writes bytes to the buffer.
156
151
/// </summary>
@@ -307,5 +302,34 @@ private void Grow(int size)
307
302
Debug . Assert ( this . bytesRead + this . AvailableReadableBytes == this . bytesWritten ) ;
308
303
this . OnResize ? . Invoke ( this , EventArgs . Empty ) ;
309
304
}
305
+
306
+ protected virtual void Dispose ( bool disposing )
307
+ {
308
+ if ( ! disposedValue )
309
+ {
310
+ if ( disposing )
311
+ {
312
+ ArrayPool < byte > . Shared . Return ( this . buffer ) ;
313
+ }
314
+
315
+ // TODO: free unmanaged resources (unmanaged objects) and override finalizer
316
+ // TODO: set large fields to null
317
+ disposedValue = true ;
318
+ }
319
+ }
320
+
321
+ // // TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources
322
+ // ~ByteBuffer()
323
+ // {
324
+ // // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
325
+ // Dispose(disposing: false);
326
+ // }
327
+
328
+ public void Dispose ( )
329
+ {
330
+ // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
331
+ Dispose ( disposing : true ) ;
332
+ GC . SuppressFinalize ( this ) ;
333
+ }
310
334
}
311
335
}
You can’t perform that action at this time.
0 commit comments