public NamedWindowConsumerLatchWait(
     NamedWindowDeltaData deltaData,
     IDictionary<EPStatementAgentInstanceHandle, IList<NamedWindowConsumerView>> dispatchTo,
     NamedWindowConsumerLatchFactory factory,
     NamedWindowConsumerLatchWait earlier)
     : base(deltaData, dispatchTo)
 {
     this.factory = factory;
     EarlierLocal = earlier;
 }
        /// <summary>
        ///     Returns a new latch.
        ///     <para />
        ///     Need not be synchronized as there is one per statement and execution is during statement lock.
        /// </summary>
        /// <param name="delta">the delta</param>
        /// <param name="consumers">consumers</param>
        /// <returns>latch</returns>
        public NamedWindowConsumerLatch NewLatch(
            NamedWindowDeltaData delta,
            IDictionary<EPStatementAgentInstanceHandle, IList<NamedWindowConsumerView>> consumers)
        {
            if (useSpin) {
                var nextLatch = new NamedWindowConsumerLatchSpin(delta, consumers, this, currentLatchSpin);
                currentLatchSpin = nextLatch;
                return nextLatch;
            }

            if (enabled) {
                var nextLatch = new NamedWindowConsumerLatchWait(delta, consumers, this, currentLatchWait);
                currentLatchWait.Later = nextLatch;
                currentLatchWait = nextLatch;
                return nextLatch;
            }

            return new NamedWindowConsumerLatchNone(delta, consumers);
        }
        /// <summary>
        ///     Ctor.
        /// </summary>
        /// <param name="name">the factory name</param>
        /// <param name="msecWait">the number of milliseconds latches will await maximally</param>
        /// <param name="locking">the blocking strategy to employ</param>
        /// <param name="timeSourceService">time source provider</param>
        /// <param name="initializeNow">for initializing</param>
        /// <param name="enabled">for active indicator</param>
        public NamedWindowConsumerLatchFactory(
            string name,
            bool enabled,
            int msecWait,
            Locking locking,
            TimeSourceService timeSourceService,
            bool initializeNow)
        {
            this.name = name;
            this.enabled = enabled;
            this.msecWait = msecWait;
            this.timeSourceService = timeSourceService;

            useSpin = enabled && locking == Locking.SPIN;

            // construct a completed latch as an initial root latch
            if (initializeNow && useSpin) {
                currentLatchSpin = new NamedWindowConsumerLatchSpin(this);
            }
            else if (initializeNow && enabled) {
                currentLatchWait = new NamedWindowConsumerLatchWait(this);
            }
        }