Dreamine.Logging 1.0.2
Dreamine.Logging 프로젝트의 API와 구성 요소를 제공합니다.
로딩중...
검색중...
일치하는것 없음
Dreamine.Logging.Sinks.AsyncQueueSink 클래스 참조sealed

더 자세히 ...

Dreamine.Logging.Sinks.AsyncQueueSink에 대한 상속 다이어그램 :
Dreamine.Logging.Sinks.AsyncQueueSink에 대한 협력 다이어그램:

Public 멤버 함수

 AsyncQueueSink (IDreamineLogSink inner, int capacity=8192, int drainBatchSize=256)
void Write (DreamineLogEntry entry)
async Task ShutdownAsync (TimeSpan timeout)
async ValueTask DisposeAsync ()
void Dispose ()

속성

long DroppedCount [get]

Private 멤버 함수

async Task RunAsync ()

Private 속성

readonly IDreamineLogSink _inner
readonly Channel< DreamineLogEntry_channel
readonly CancellationTokenSource _cts = new()
readonly Task _workerTask
readonly int _drainBatchSize
long _droppedCount
int _disposed

상세한 설명

동기 로그 출력을 제한된 백그라운드 큐로 감쌉니다.

호출자는 비차단으로 항목을 큐에 넣고 단일 워커가 내부 출력으로 전달합니다. 큐가 차면 가장 오래된 항목을 버립니다.

AsyncQueueSink.cs 파일의 27 번째 라인에서 정의되었습니다.

생성자 & 소멸자 문서화

◆ AsyncQueueSink()

Dreamine.Logging.Sinks.AsyncQueueSink.AsyncQueueSink ( IDreamineLogSink inner,
int capacity = 8192,
int drainBatchSize = 256 )
inline

내부 출력과 큐 설정으로 T:Dreamine.Logging.Sinks.AsyncQueueSink를 초기화합니다.

매개변수
inner항목을 전달할 동기 출력입니다.
capacity최대 대기 항목 수입니다.
drainBatchSize내부 출력과 큐 설정으로 T:Dreamine.Logging.Sinks.AsyncQueueSink를 초기화합니다.
예외
ArgumentNullExceptioninnernull인 경우 발생합니다.
ArgumentOutOfRangeException용량 또는 배치 크기가 0 이하인 경우 발생합니다.

AsyncQueueSink.cs 파일의 151 번째 라인에서 정의되었습니다.

155 {
156 _inner = inner ?? throw new ArgumentNullException(nameof(inner));
157
158 if (capacity <= 0)
159 {
160 throw new ArgumentOutOfRangeException(nameof(capacity));
161 }
162
163 if (drainBatchSize <= 0)
164 {
165 throw new ArgumentOutOfRangeException(nameof(drainBatchSize));
166 }
167
168 _drainBatchSize = drainBatchSize;
169
170 var options = new BoundedChannelOptions(capacity)
171 {
172 FullMode = BoundedChannelFullMode.DropOldest,
173 SingleReader = true,
174 SingleWriter = false,
175 AllowSynchronousContinuations = false
176 };
177
178 _channel = Channel.CreateBounded<DreamineLogEntry>(options);
179
180 _workerTask = Task.Factory.StartNew(
181 RunAsync,
182 CancellationToken.None,
183 TaskCreationOptions.LongRunning,
184 TaskScheduler.Default).Unwrap();
185 }

다음을 참조함 : _channel, _drainBatchSize, _inner, _workerTask, RunAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

멤버 함수 문서화

◆ Dispose()

void Dreamine.Logging.Sinks.AsyncQueueSink.Dispose ( )
inline

기본 제한 시간으로 큐를 동기 종료하고 오류를 억제합니다.

AsyncQueueSink.cs 파일의 398 번째 라인에서 정의되었습니다.

399 {
400 try
401 {
402 ShutdownAsync(TimeSpan.FromSeconds(2)).GetAwaiter().GetResult();
403 }
404 catch
405 {
406 // Suppress on dispose.
407 }
408 }

다음을 참조함 : ShutdownAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ DisposeAsync()

async ValueTask Dreamine.Logging.Sinks.AsyncQueueSink.DisposeAsync ( )
inline

기본 제한 시간으로 큐를 종료하고 리소스를 비동기 해제합니다.

반환값
비동기 해제 작업입니다.

AsyncQueueSink.cs 파일의 385 번째 라인에서 정의되었습니다.

386 {
387 await ShutdownAsync(TimeSpan.FromSeconds(2)).ConfigureAwait(false);
388 }

다음을 참조함 : ShutdownAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ RunAsync()

async Task Dreamine.Logging.Sinks.AsyncQueueSink.RunAsync ( )
inlineprivate

큐를 배치 단위로 비우고 내부 출력에 전달하는 전용 워커를 실행합니다.

반환값
워커 수명 작업입니다.

AsyncQueueSink.cs 파일의 252 번째 라인에서 정의되었습니다.

253 {
254 var reader = _channel.Reader;
255 var batch = new List<DreamineLogEntry>(_drainBatchSize);
256
257 try
258 {
259 while (await reader.WaitToReadAsync(_cts.Token).ConfigureAwait(false))
260 {
261 batch.Clear();
262
263 while (batch.Count < _drainBatchSize && reader.TryRead(out var entry))
264 {
265 batch.Add(entry);
266 }
267
268 foreach (var item in batch)
269 {
270 try
271 {
272 _inner.Write(item);
273 }
274 catch
275 {
276 // Logging failure must not terminate the application.
277 }
278 }
279 }
280 }
281 catch (OperationCanceledException)
282 {
283 // Expected on shutdown.
284 }
285 catch
286 {
287 // Defensive: never let the worker crash silently kill the channel.
288 }
289 }

다음을 참조함 : _channel, _cts, _drainBatchSize, _inner.

다음에 의해서 참조됨 : AsyncQueueSink().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ ShutdownAsync()

async Task Dreamine.Logging.Sinks.AsyncQueueSink.ShutdownAsync ( TimeSpan timeout)
inline

새 항목 수락을 중지하고 대기 항목이 처리될 때까지 기다립니다.

매개변수
timeout워커 종료를 기다릴 최대 시간입니다.
반환값
비동기 종료 작업입니다.

AsyncQueueSink.cs 파일의 315 번째 라인에서 정의되었습니다.

316 {
317 if (Interlocked.Exchange(ref _disposed, 1) != 0)
318 {
319 return;
320 }
321
322 _channel.Writer.TryComplete();
323
324 using var timeoutCts = new CancellationTokenSource(timeout);
325 try
326 {
327 await _workerTask.WaitAsync(timeoutCts.Token).ConfigureAwait(false);
328 }
329 catch (OperationCanceledException)
330 {
331 _cts.Cancel();
332 try
333 {
334 await _workerTask.ConfigureAwait(false);
335 }
336 catch
337 {
338 // Suppress shutdown errors.
339 }
340 }
341
342 // Best-effort dispose on the inner sink so file handles are closed.
343 if (_inner is IAsyncDisposable asyncDisposable)
344 {
345 try
346 {
347 await asyncDisposable.DisposeAsync().ConfigureAwait(false);
348 }
349 catch
350 {
351 // Suppress on shutdown.
352 }
353 }
354 else if (_inner is IDisposable disposable)
355 {
356 try
357 {
358 disposable.Dispose();
359 }
360 catch
361 {
362 // Suppress on shutdown.
363 }
364 }
365
366 _cts.Dispose();
367 }

다음을 참조함 : _channel, _cts, _disposed, _inner, _workerTask.

다음에 의해서 참조됨 : Dispose(), DisposeAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ Write()

void Dreamine.Logging.Sinks.AsyncQueueSink.Write ( DreamineLogEntry entry)
inline

로그 항목을 비차단 방식으로 백그라운드 큐에 추가합니다.

매개변수
entry추가할 로그 항목입니다.
예외
ArgumentNullExceptionentrynull인 경우 발생합니다.

로그 항목을 비차단 방식으로 백그라운드 큐에 추가합니다.

Dreamine.Logging.Interfaces.IDreamineLogSink를 구현.

AsyncQueueSink.cs 파일의 219 번째 라인에서 정의되었습니다.

220 {
221 ArgumentNullException.ThrowIfNull(entry);
222
223 if (Volatile.Read(ref _disposed) != 0)
224 {
225 return;
226 }
227
228 // BoundedChannelFullMode.DropOldest guarantees TryWrite always succeeds
229 // unless the channel is completed.
230 if (!_channel.Writer.TryWrite(entry))
231 {
232 Interlocked.Increment(ref _droppedCount);
233 }
234 }

다음을 참조함 : _channel, _disposed, _droppedCount.

멤버 데이터 문서화

◆ _channel

readonly Channel<DreamineLogEntry> Dreamine.Logging.Sinks.AsyncQueueSink._channel
private

channel 값을 보관합니다.

AsyncQueueSink.cs 파일의 46 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : AsyncQueueSink(), RunAsync(), ShutdownAsync(), Write().

◆ _cts

readonly CancellationTokenSource Dreamine.Logging.Sinks.AsyncQueueSink._cts = new()
private

cts 값을 보관합니다.

AsyncQueueSink.cs 파일의 55 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : RunAsync(), ShutdownAsync().

◆ _disposed

int Dreamine.Logging.Sinks.AsyncQueueSink._disposed
private

disposed 값을 보관합니다.

AsyncQueueSink.cs 파일의 91 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : ShutdownAsync(), Write().

◆ _drainBatchSize

readonly int Dreamine.Logging.Sinks.AsyncQueueSink._drainBatchSize
private

drain Batch Size 값을 보관합니다.

AsyncQueueSink.cs 파일의 73 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : AsyncQueueSink(), RunAsync().

◆ _droppedCount

long Dreamine.Logging.Sinks.AsyncQueueSink._droppedCount
private

dropped Count 값을 보관합니다.

AsyncQueueSink.cs 파일의 82 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : Write().

◆ _inner

readonly IDreamineLogSink Dreamine.Logging.Sinks.AsyncQueueSink._inner
private

inner 값을 보관합니다.

AsyncQueueSink.cs 파일의 37 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : AsyncQueueSink(), RunAsync(), ShutdownAsync().

◆ _workerTask

readonly Task Dreamine.Logging.Sinks.AsyncQueueSink._workerTask
private

worker Task 값을 보관합니다.

AsyncQueueSink.cs 파일의 64 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : AsyncQueueSink(), ShutdownAsync().

속성 문서화

◆ DroppedCount

long Dreamine.Logging.Sinks.AsyncQueueSink.DroppedCount
get

큐가 가득 차서 버려진 항목 수를 가져옵니다.

AsyncQueueSink.cs 파일의 101 번째 라인에서 정의되었습니다.


이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.: