Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }