Class ChunkedStream
Represents a stream that will flush after a certain size or time threshold.
Namespace: Unity.Simulation
Syntax
public class ChunkedStream : IDisposable
Constructors
ChunkedStream(Int32, Single, Func<AsyncRequest<Object>, AsyncRequest.Result>)
Constructs a stream object.
Declaration
public ChunkedStream(int bufferSize = 8192, float maxElapsedSeconds = 5F, Func<AsyncRequest<object>, AsyncRequest.Result> functor = null)
Parameters
Type | Name | Description |
---|---|---|
Int32 | bufferSize | Size of the buffer in bytes. |
Single | maxElapsedSeconds | Amount of time after which the buffer will automatically flush. |
Func<AsyncRequest<Object>, AsyncRequest.Result> | functor | Callback function to pass buffered data to. |
Fields
kDefaultBufferSize
The default stream buffer size.
Declaration
public const int kDefaultBufferSize = 8192
Field Value
Type | Description |
---|---|
Int32 |
kDefaultMaxSecondsElapsed
The default flush time in seconds.
Declaration
public const float kDefaultMaxSecondsElapsed = 5F
Field Value
Type | Description |
---|---|
Single |
Properties
functor
Callback functor to call when flush occurs. Accumulated data thus far is passed to functor.
Declaration
public Func<AsyncRequest<object>, AsyncRequest.Result> functor { get; set; }
Property Value
Type | Description |
---|---|
Func<AsyncRequest<Object>, AsyncRequest.Result> |
Methods
Append(Byte[])
Append the data to the byte buffer
Declaration
public void Append(byte[] data)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | data | byte array of the data to be appended. |
Dispose()
Disposes of the stream and removes it from Tick.
Declaration
public void Dispose()
Flush(Boolean)
Write the data in the buffer to the file system.
Declaration
public void Flush(bool synchronous = false)
Parameters
Type | Name | Description |
---|---|---|
Boolean | synchronous |