Example #1
0
 /// <summary>
 ///     Ctor.
 /// </summary>
 /// <param name="earlier">the latch before this latch that this latch should be waiting for</param>
 /// <param name="msecTimeout">the timeout after which delivery occurs</param>
 /// <param name="payload">the payload is an event to deliver</param>
 public InsertIntoLatchWait(
     InsertIntoLatchWait earlier,
     int msecTimeout,
     EventBean payload)
 {
     this._earlier = earlier;
     this._msecTimeout = msecTimeout;
     this._payload = payload;
 }
Example #2
0
        /// <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="payload">is the object returned by the await.</param>
        /// <returns>latch</returns>
        public object NewLatch(EventBean payload)
        {
            if (stateless) {
                return payload;
            }

            if (useSpin) {
                var nextLatch = new InsertIntoLatchSpin(this, currentLatchSpin, msecWait, payload);
                currentLatchSpin = nextLatch;
                return nextLatch;
            }
            else {
                var nextLatch = new InsertIntoLatchWait(currentLatchWait, msecWait, payload);
                currentLatchWait.Later = nextLatch;
                currentLatchWait = nextLatch;
                return nextLatch;
            }
        }
Example #3
0
        /// <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="stateless">indicator whether stateless</param>
        public InsertIntoLatchFactory(
            string name,
            bool stateless,
            int msecWait,
            Locking locking,
            TimeSourceService timeSourceService)
        {
            Name = name;
            this.msecWait = msecWait;
            TimeSourceService = timeSourceService;
            this.stateless = stateless;

            useSpin = locking == Locking.SPIN;

            // construct a completed latch as an initial root latch
            if (useSpin) {
                currentLatchSpin = new InsertIntoLatchSpin(this);
            }
            else {
                currentLatchWait = new InsertIntoLatchWait(this);
            }
        }
Example #4
0
 /// <summary>
 ///     Ctor - use for the first and unused latch to indicate completion.
 /// </summary>
 /// <param name="factory">the latch factory</param>
 public InsertIntoLatchWait(InsertIntoLatchFactory factory)
 {
     _isCompleted = true;
     _earlier = null;
     _msecTimeout = 0;
 }