Struct DispatchQueue
Double buffered thread-safe queue that is used by com.unity.logging. One buffer is used for write: several threads can add new LogMessage's to it Second one is used as read-only buffer: sinks and logging system's cleanup system read it. Cleanup system calls EndReadClearAndFlip() at the end of its work, cleaning read-only buffer and flipping write/read-only ones.
Namespace: Unity.Logging
Syntax
public struct DispatchQueue : IDisposable
Constructors
DispatchQueue(Int32)
Constructor for DispatchQueue. Will create two lists with size =
Declaration
public DispatchQueue(int size)
Parameters
Type | Name | Description |
---|---|---|
Int32 | size | Max length of the queue |
Properties
IsCreated
Is true if this struct was initialized.
Declaration
public readonly bool IsCreated { get; }
Property Value
Type | Description |
---|---|
Boolean |
TotalLength
Total length of read-only and write buffers. Usually used for testing of internal state of the queue.
Declaration
public readonly int TotalLength { get; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
BeginRead()
Puts DispatchQueue into reading lock mode till EndRead
or EndReadClearAndFlip
is called to prevent buffer flipping.
Declaration
public UnsafeList<LogMessage>.ParallelReader BeginRead()
Returns
Type | Description |
---|---|
UnsafeList.ParallelReader<> | ParallelReader is returned that can be used to get all the LogMessage's from read-only buffer |
Dispose()
Dispose call that will call Dispose for the lists (under lock) if IsCreated is true.
Declaration
public void Dispose()
EndRead()
Unlocks DispatchQueue reading lock that was initiated by BeginRead()
Declaration
public void EndRead()
EndReadClearAndFlip()
Clears read-only buffer and swaps it with write buffer. Then unlocks DispatchQueue reading lock that was initiated by BeginRead()
Declaration
public void EndReadClearAndFlip()
Enqueue(ref LogMessage)
Declaration
public void Enqueue(ref LogMessage message)
Parameters
Type | Name | Description |
---|---|---|
LogMessage | message |