Esempio n. 1
0
        public void Release(RequestEvent @event)
        {
            if (@event.Owner != this)
            {
                throw new InvalidOperationException("not owned by this");
            }

            if (@event.IsReleased)
            {
                return;
            }

            @event.Release();

            if ([email protected]) //reneg
            {
                _waiting.Remove(@event);
                return;
            }

            _using--;

            if (_waiting.Count > 0)
            {
                RequestEvent first = _waiting.First.Value;
                _waiting.RemoveFirst();
                _using++;
                first.Fire();
            }
        }
Esempio n. 2
0
        public RequestEvent Request()
        {
            var e = new RequestEvent(this);

            if (_using < _capacity)
            {
                _using++;
                e.Fire();
            }
            else
            {
                _waiting.AddLast(e);
            }
            return(e);
        }