public ReactorThreadInvokerQueue() { _queue = new ReactorQueue<QueueDelegate>(256); _blockingInvoker = new BlockingReactorThreadInvoker(this); _eventInvoker = new EventReactorThreadInvoker(this); }
public void Open(IServiceHost host) { _queue = new ReactorQueue<int>(_capacity); _finishedEvent = new ManualResetEvent(false); _isFinished = false; _dequeuedObjects = new List<int>(); _queue.StartDequeuingToCallback(host.Reactor, DequeueCallback); }
public void Close(IServiceHost host) { _queue.StopDequeuingToCallback(); if (!_isFinished) _finishedEvent.Set(); _finishedEvent.Close(); _queue = null; _finishedEvent = null; _isFinished = true; _dequeuedObjects = null; }
void DequeueCallback(ReactorQueue<int> queue, int item) { _dequeuedObjects.Add(item); if (!_isFinished && _predicate(_dequeuedObjects)) { _isFinished = true; _finishedEvent.Set(); } }
void InvokeDequeued(ReactorQueue<QueueDelegate> queue, QueueDelegate item) { item.Invoke(); }