tgstation-server 6.17.0
The /tg/station 13 server suite
|
IFileStreamProvider that provides a ISeekableFileStreamProvider from an input Stream. More...
Public Member Functions | |||
BufferedFileStreamProvider (Stream input) | |||
Initializes a new instance of the BufferedFileStreamProvider class. | |||
async ValueTask | DisposeAsync () | ||
async ValueTask< Stream > | GetResult (CancellationToken cancellationToken) | ||
Gets the provided Stream. May be called multiple times, though cancelling any may cause all calls to be cancelled. All calls yield the same Stream reference.
| |||
async ValueTask< MemoryStream > | GetOwnedResult (CancellationToken cancellationToken) | ||
Gets the provided MemoryStream. May be called multiple times, though cancelling any may cause all calls to be cancelled.
| |||
Task | EnsureBuffered (CancellationToken cancellationToken) | ||
Ensures the input Stream has been copied to the buffer. | |||
Properties | |
bool | Disposed [get] |
If the ISeekableFileStreamProvider has had global::System.IAsyncDisposable.DisposeAsync called on it. | |
![]() |
Private Member Functions | |
async ValueTask<(MemoryStream Stream, long StreamLength)> | GetResultInternal (CancellationToken cancellationToken) |
Gets the shared MemoryStream and its Stream.Length. | |
Private Attributes | |
readonly Stream | input |
The original input Stream must remain valid for the lifetime of the BufferedFileStreamProvider or until GetResult(CancellationToken) first returns. | |
readonly SemaphoreSlim | semaphore |
The SemaphoreSlim used to synchronize writes to buffer. | |
volatile? MemoryStream | buffer |
The backing Stream. | |
volatile bool | buffered |
If buffer has been populated. | |
IFileStreamProvider that provides a ISeekableFileStreamProvider from an input Stream.
Definition at line 13 of file BufferedFileStreamProvider.cs.
Tgstation.Server.Host.IO.BufferedFileStreamProvider.BufferedFileStreamProvider | ( | Stream | input | ) |
Initializes a new instance of the BufferedFileStreamProvider class.
input | The value of input. |
Definition at line 42 of file BufferedFileStreamProvider.cs.
References Tgstation.Server.Host.IO.BufferedFileStreamProvider.buffer, Tgstation.Server.Host.IO.BufferedFileStreamProvider.input, and Tgstation.Server.Host.IO.BufferedFileStreamProvider.semaphore.
async ValueTask Tgstation.Server.Host.IO.BufferedFileStreamProvider.DisposeAsync | ( | ) |
Definition at line 59 of file BufferedFileStreamProvider.cs.
References Tgstation.Server.Host.IO.BufferedFileStreamProvider.buffer, Tgstation.Server.Host.IO.BufferedFileStreamProvider.buffered, and Tgstation.Server.Host.IO.BufferedFileStreamProvider.semaphore.
Task Tgstation.Server.Host.IO.BufferedFileStreamProvider.EnsureBuffered | ( | CancellationToken | cancellationToken | ) |
Ensures the input Stream has been copied to the buffer.
cancellationToken | The CancellationToken for the operation. |
async ValueTask< MemoryStream > Tgstation.Server.Host.IO.BufferedFileStreamProvider.GetOwnedResult | ( | CancellationToken | cancellationToken | ) |
Gets the provided MemoryStream. May be called multiple times, though cancelling any may cause all calls to be cancelled.
cancellationToken | The CancellationToken for the operation. |
Implements Tgstation.Server.Host.IO.ISeekableFileStreamProvider.
Definition at line 87 of file BufferedFileStreamProvider.cs.
References Tgstation.Server.Host.IO.BufferedFileStreamProvider.GetResultInternal().
async ValueTask< Stream > Tgstation.Server.Host.IO.BufferedFileStreamProvider.GetResult | ( | CancellationToken | cancellationToken | ) |
Gets the provided Stream. May be called multiple times, though cancelling any may cause all calls to be cancelled. All calls yield the same Stream reference.
cancellationToken | The CancellationToken for the operation. |
Implements Tgstation.Server.Host.IO.IFileStreamProvider.
Definition at line 80 of file BufferedFileStreamProvider.cs.
References Tgstation.Server.Host.IO.BufferedFileStreamProvider.GetResultInternal().
|
private |
Gets the shared MemoryStream and its Stream.Length.
cancellationToken | The CancellationToken for the operation. |
Definition at line 105 of file BufferedFileStreamProvider.cs.
References Tgstation.Server.Host.IO.BufferedFileStreamProvider.buffer, Tgstation.Server.Host.IO.BufferedFileStreamProvider.buffered, Tgstation.Server.Host.IO.BufferedFileStreamProvider.input, Tgstation.Server.Host.Utils.SemaphoreSlimContext.Lock(), and Tgstation.Server.Host.IO.BufferedFileStreamProvider.semaphore.
Referenced by Tgstation.Server.Host.IO.BufferedFileStreamProvider.GetOwnedResult(), and Tgstation.Server.Host.IO.BufferedFileStreamProvider.GetResult().
|
private |
The backing Stream.
Definition at line 31 of file BufferedFileStreamProvider.cs.
Referenced by Tgstation.Server.Host.IO.BufferedFileStreamProvider.BufferedFileStreamProvider(), Tgstation.Server.Host.IO.BufferedFileStreamProvider.DisposeAsync(), and Tgstation.Server.Host.IO.BufferedFileStreamProvider.GetResultInternal().
|
private |
If buffer has been populated.
Definition at line 36 of file BufferedFileStreamProvider.cs.
Referenced by Tgstation.Server.Host.IO.BufferedFileStreamProvider.DisposeAsync(), and Tgstation.Server.Host.IO.BufferedFileStreamProvider.GetResultInternal().
|
private |
The original input Stream must remain valid for the lifetime of the BufferedFileStreamProvider or until GetResult(CancellationToken) first returns.
Definition at line 21 of file BufferedFileStreamProvider.cs.
Referenced by Tgstation.Server.Host.IO.BufferedFileStreamProvider.BufferedFileStreamProvider(), and Tgstation.Server.Host.IO.BufferedFileStreamProvider.GetResultInternal().
|
private |
The SemaphoreSlim used to synchronize writes to buffer.
Definition at line 26 of file BufferedFileStreamProvider.cs.
Referenced by Tgstation.Server.Host.IO.BufferedFileStreamProvider.BufferedFileStreamProvider(), Tgstation.Server.Host.IO.BufferedFileStreamProvider.DisposeAsync(), and Tgstation.Server.Host.IO.BufferedFileStreamProvider.GetResultInternal().
|
get |
If the ISeekableFileStreamProvider has had global::System.IAsyncDisposable.DisposeAsync called on it.
Implements Tgstation.Server.Host.IO.ISeekableFileStreamProvider.
Definition at line 16 of file BufferedFileStreamProvider.cs.