Dreamine.Logging.Wpf 1.0.2
Dreamine.Logging.Wpf 사용자 인터페이스 기능과 구성 요소를 제공합니다.
로딩중...
검색중...
일치하는것 없음
Dreamine.Logging.Wpf.Services.BatchedDispatcher< T > 클래스 템플릿 참조sealed

더 자세히 ...

Public 멤버 함수

 BatchedDispatcher (Dispatcher dispatcher, Action< IReadOnlyList< T > > onBatch, DispatcherPriority priority=DispatcherPriority.Background)
void Enqueue (T item)

정적 Public 속성

const int MaxBatchSize = 256

Private 멤버 함수

void ScheduleFlushIfNeeded ()
void Flush ()

Private 속성

readonly Dispatcher _dispatcher
readonly Action< IReadOnlyList< T > > _onBatch
readonly DispatcherPriority _priority
readonly ConcurrentQueue< T > _pending = new()
int _scheduled

상세한 설명

빈번한 UI 갱신을 WPF UI 스레드에서 처리할 배치로 합칩니다.

모든 스레드에서 항목을 추가할 수 있으며 한 번에 하나의 디스패처 작업만 예약하고 배치 크기를 제한합니다.

템플릿 파라메터
T전달할 항목 타입입니다.

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

멤버 함수 문서화

◆ BatchedDispatcher()

Dreamine.Logging.Wpf.Services.BatchedDispatcher< T >.BatchedDispatcher ( Dispatcher dispatcher,
Action< IReadOnlyList< T > > onBatch,
DispatcherPriority priority = DispatcherPriority::Background )
inline

디스패처, 배치 콜백 및 우선순위로 T:Dreamine.Logging.Wpf.Services.BatchedDispatcher`1를 초기화합니다.

매개변수
dispatcher대상 WPF 디스패처입니다.
onBatchUI 스레드에서 배치와 함께 호출할 콜백입니다.
priority디스패처 우선순위입니다.
예외
ArgumentNullException디스패처 또는 콜백이 null인 경우 발생합니다.

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

135 {
136 _dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher));
137 _onBatch = onBatch ?? throw new ArgumentNullException(nameof(onBatch));
138 _priority = priority;
139 }

다음을 참조함 : _dispatcher, _onBatch, _priority.

◆ Enqueue()

void Dreamine.Logging.Wpf.Services.BatchedDispatcher< T >.Enqueue ( T item)
inline

UI 배치 전달을 위해 항목을 큐에 추가합니다.

매개변수
item전달할 항목입니다.

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

158 {
159 _pending.Enqueue(item);
160 ScheduleFlushIfNeeded();
161 }

다음을 참조함 : _pending, ScheduleFlushIfNeeded().

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

◆ Flush()

void Dreamine.Logging.Wpf.Services.BatchedDispatcher< T >.Flush ( )
inlineprivate

대기 항목을 제한 크기 배치로 꺼내 콜백에 전달하고 남은 작업을 다시 예약합니다.

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

191 {
192 try
193 {
194 var buffer = new List<T>(Math.Min(_pending.Count, MaxBatchSize));
195
196 while (buffer.Count < MaxBatchSize && _pending.TryDequeue(out var item))
197 {
198 buffer.Add(item);
199 }
200
201 if (buffer.Count > 0)
202 {
203 _onBatch(buffer);
204 }
205 }
206 finally
207 {
208 Volatile.Write(ref _scheduled, 0);
209
210 // Re-arm if producers added more while we were running.
211 if (!_pending.IsEmpty)
212 {
213 ScheduleFlushIfNeeded();
214 }
215 }
216 }

다음을 참조함 : _onBatch, _pending, _scheduled, MaxBatchSize, ScheduleFlushIfNeeded().

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

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

◆ ScheduleFlushIfNeeded()

void Dreamine.Logging.Wpf.Services.BatchedDispatcher< T >.ScheduleFlushIfNeeded ( )
inlineprivate

예약된 작업이 없으면 UI 큐 비우기 작업을 예약합니다.

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

172 {
173 // Ensure only one DispatcherOperation is pending at any time.
174 if (Interlocked.CompareExchange(ref _scheduled, 1, 0) != 0)
175 {
176 return;
177 }
178
179 _dispatcher.BeginInvoke(_priority, new Action(Flush));
180 }

다음을 참조함 : _dispatcher, _priority, _scheduled, Flush().

다음에 의해서 참조됨 : Enqueue(), Flush().

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

멤버 데이터 문서화

◆ _dispatcher

readonly Dispatcher Dreamine.Logging.Wpf.Services.BatchedDispatcher< T >._dispatcher
private

dispatcher 값을 보관합니다.

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

다음에 의해서 참조됨 : BatchedDispatcher(), ScheduleFlushIfNeeded().

◆ _onBatch

readonly Action<IReadOnlyList<T> > Dreamine.Logging.Wpf.Services.BatchedDispatcher< T >._onBatch
private

on Batch 값을 보관합니다.

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

다음에 의해서 참조됨 : BatchedDispatcher(), Flush().

◆ _pending

readonly ConcurrentQueue<T> Dreamine.Logging.Wpf.Services.BatchedDispatcher< T >._pending = new()
private

pending 값을 보관합니다.

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

다음에 의해서 참조됨 : Enqueue(), Flush().

◆ _priority

readonly DispatcherPriority Dreamine.Logging.Wpf.Services.BatchedDispatcher< T >._priority
private

priority 값을 보관합니다.

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

다음에 의해서 참조됨 : BatchedDispatcher(), ScheduleFlushIfNeeded().

◆ _scheduled

int Dreamine.Logging.Wpf.Services.BatchedDispatcher< T >._scheduled
private

scheduled 값을 보관합니다.

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

다음에 의해서 참조됨 : Flush(), ScheduleFlushIfNeeded().

◆ MaxBatchSize

const int Dreamine.Logging.Wpf.Services.BatchedDispatcher< T >.MaxBatchSize = 256
static

한 UI 스레드 배치에서 처리할 최대 항목 수입니다.

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

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


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