/// <summary> /// Ctor - use for the first and unused latch to indicate completion. /// </summary> public NamedWindowConsumerLatchWait(NamedWindowConsumerLatchFactory factory) : base(null, null) { _factory = factory; _isCompleted = true; _earlier = null; }
/// <summary> /// Called to indicate that the latch completed and a later latch can start. /// </summary> public override void Done() { _isCompleted = true; if (_later != null) { lock (_later) { Monitor.Pulse(_later); } } _earlier = null; _later = null; }
/// <summary> /// Ctor. /// </summary> /// <param name="name">the factory name</param> /// <param name="enabled"></param> /// <param name="msecWait">the number of milliseconds latches will await maximually</param> /// <param name="locking">the blocking strategy to employ</param> /// <param name="timeSourceService">time source provider</param> /// <param name="initializenow"></param> public NamedWindowConsumerLatchFactory(string name, bool enabled, long msecWait, ConfigurationEngineDefaults.Threading.Locking locking, TimeSourceService timeSourceService, bool initializenow) { Name = name; Enabled = enabled; MsecWait = msecWait; TimeSourceService = timeSourceService; UseSpin = enabled && (locking == ConfigurationEngineDefaults.Threading.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); } }
/// <summary> /// Returns a new latch. /// <para />Need not be synchronized as there is one per statement and execution is during statement lock. /// </summary> /// <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); } else { 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="earlier">the latch before this latch that this latch should be waiting for</param> public NamedWindowConsumerLatchWait(NamedWindowDeltaData deltaData, IDictionary <EPStatementAgentInstanceHandle, IList <NamedWindowConsumerView> > dispatchTo, NamedWindowConsumerLatchFactory factory, NamedWindowConsumerLatchWait earlier) : base(deltaData, dispatchTo) { _factory = factory; _earlier = earlier; }