public void Dispose() { lock (_lock) { while (_events.Count > 0) { CounterQueueEvent evt = _events.Dequeue(); evt.Dispose(); } Disposed = true; } _queuedEvent.Set(); _consumerThread.Join(); foreach (BufferedQuery query in _queryPool) { query.Dispose(); } _queuedEvent.Dispose(); _wakeSignal.Dispose(); _eventConsumed.Dispose(); }
public CounterQueueEvent QueueReport(EventHandler <ulong> resultHandler, ulong lastDrawIndex) { CounterQueueEvent result; ulong draws = lastDrawIndex - _current.DrawIndex; lock (_lock) { // A query's result only matters if more than one draw was performed during it. // Otherwise, dummy it out and return 0 immediately. if (draws > 0) { _current.Complete(true); _events.Enqueue(_current); _current.OnResult += resultHandler; } else { _current.Complete(false); _current.Dispose(); resultHandler(_current, 0); } result = _current; _current = new CounterQueueEvent(this, GetTarget(Type), lastDrawIndex); } _queuedEvent.Set(); return(result); }
public CounterQueueEvent QueueReport(EventHandler <ulong> resultHandler, ulong lastDrawIndex, bool hostReserved) { CounterQueueEvent result; ulong draws = lastDrawIndex - _current.DrawIndex; lock (_lock) { // A query's result only matters if more than one draw was performed during it. // Otherwise, dummy it out and return 0 immediately. if (hostReserved) { // This counter event is guaranteed to be available for host conditional rendering. _current.ReserveForHostAccess(); } if (draws > 0) { _current.Complete(true); _events.Enqueue(_current); _current.OnResult += resultHandler; } else { _current.Complete(false); _current.Dispose(); resultHandler(_current, 0); } result = _current; _current = new CounterQueueEvent(this, GetTarget(Type), lastDrawIndex); } _queuedEvent.Set(); return(result); }