Table of Contents

Struct BufferLock

Namespace
ReFuel.Resources
Assembly
ReFuel.dll

An object that provides exclusive r/w access to a buffer.

public ref struct BufferLock
Inherited Members

Constructors

BufferLock(IBufferProvider, ReadOnlySpan<byte>, IDisposable?)

public BufferLock(IBufferProvider provider, ReadOnlySpan<byte> span, IDisposable? disposer = null)

Parameters

provider IBufferProvider
span ReadOnlySpan<byte>
disposer IDisposable

BufferLock(IBufferProvider, Span<byte>, bool, IDisposable?)

public BufferLock(IBufferProvider provider, Span<byte> span, bool isReadonly = true, IDisposable? disposer = null)

Parameters

provider IBufferProvider
span Span<byte>
isReadonly bool
disposer IDisposable

Properties

IsDisposed

public bool IsDisposed { get; }

Property Value

bool

IsReadOnly

Is this lock read-only?

public readonly bool IsReadOnly { get; }

Property Value

bool

Methods

AsSpan()

Get the buffer contents as a ReadOnlySpan<T>.

public ReadOnlySpan<byte> AsSpan()

Returns

ReadOnlySpan<byte>

The buffer contents.

AsSpan<T>()

Get the buffer contents as a ReadOnlySpan<T>.

public ReadOnlySpan<T> AsSpan<T>() where T : struct

Returns

ReadOnlySpan<T>

The buffer contents.

Type Parameters

T

The type to cast the buffer to

AsWriteSpan()

Get the buffer contents as a ReadOnlySpan<T>.

public Span<byte> AsWriteSpan()

Returns

Span<byte>

The buffer contents.

AsWriteSpan<T>()

Get the buffer contents as a Span<T>.

public Span<T> AsWriteSpan<T>() where T : struct

Returns

Span<T>

The buffer contents.

Type Parameters

T

The type to cast the buffer to

Dispose()

Release the lock.

public void Dispose()

Operators

implicit operator ReadOnlySpan<byte>(in BufferLock)

Cast operator.

public static implicit operator ReadOnlySpan<byte>(in BufferLock @lock)

Parameters

lock BufferLock

The lock to cast.

Returns

ReadOnlySpan<byte>

implicit operator Span<byte>(in BufferLock)

Cast operator.

public static implicit operator Span<byte>(in BufferLock @lock)

Parameters

lock BufferLock

The lock to cast.

Returns

Span<byte>