コード例 #1
0
		// Methods
		public void Add (TimerEventSubscription item)
		{
			int range = list.Count;
			int middle, cmp;
			int left = 0;
			int right = range-1;

			// Adds items always in a sorted order
			while (left <= right) {

				middle = (left + right) >> 1;
				cmp = Comparer.Default.Compare (item.ExpiresAt,
					((TimerEventSubscription) list [middle]).ExpiresAt);

				if (cmp == 0) {
					break;
				}

				if (cmp >  0) {
					left = middle + 1;
				}
				else {
					right = middle - 1;
				}
			}

			list.Insert (left, item);
		}
コード例 #2
0
        // Methods
        public void Add(TimerEventSubscription item)
        {
            int range = list.Count;
            int middle, cmp;
            int left  = 0;
            int right = range - 1;

            // Adds items always in a sorted order
            while (left <= right)
            {
                middle = (left + right) >> 1;
                cmp    = Comparer.Default.Compare(item.ExpiresAt,
                                                  ((TimerEventSubscription)list [middle]).ExpiresAt);

                if (cmp == 0)
                {
                    break;
                }

                if (cmp > 0)
                {
                    left = middle + 1;
                }
                else
                {
                    right = middle - 1;
                }
            }

            list.Insert(left, item);
        }
コード例 #3
0
 internal void Enqueue(TimerEventSubscription timerEventSubscription)
 {
     lock (locker)
     {
         WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "TimerEventSubscriptionQueue: {0} Enqueue Timer {1} for {2} ", instanceId, timerEventSubscription.SubscriptionId, timerEventSubscription.ExpiresAt);
         queue.Enqueue(timerEventSubscription.SubscriptionId, timerEventSubscription, timerEventSubscription.ExpiresAt);
     }
 }
コード例 #4
0
 public void Remove(TimerEventSubscription item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     this.Remove(item.SubscriptionId);
 }
 public void Add(TimerEventSubscription item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     this.Enqueue(item);
 }
コード例 #6
0
 public void Add(TimerEventSubscription item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     this.Enqueue(item);
 }
コード例 #7
0
 internal void Enqueue(TimerEventSubscription timerEventSubscription)
 {
     lock (this.locker)
     {
         WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "TimerEventSubscriptionQueue: {0} Enqueue Timer {1} for {2} ", new object[] { this.instanceId, timerEventSubscription.SubscriptionId, timerEventSubscription.ExpiresAt });
         this.queue.Enqueue(timerEventSubscription.SubscriptionId, timerEventSubscription, timerEventSubscription.ExpiresAt);
     }
 }
コード例 #8
0
		public void Constructor2 ()
		{
			TimerEventSubscription timer;
			Guid workflowInstanceId = Guid.NewGuid ();
			DateTime expiresAt = DateTime.Today;

			timer = new TimerEventSubscription (workflowInstanceId, expiresAt);
			Assert.AreEqual (workflowInstanceId, timer.WorkflowInstanceId, "C1#1");
			Assert.AreEqual (timer.SubscriptionId, timer.QueueName, "C1#2");
		}
コード例 #9
0
 internal TimerEventSubscription Dequeue()
 {
     lock (locker)
     {
         TimerEventSubscription retval = queue.Dequeue();
         if (retval != null)
         {
             WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "TimerEventSubscriptionQueue: {0} Dequeue Timer {1} for {2} ", instanceId, retval.SubscriptionId, retval.ExpiresAt);
         }
         return(retval);
     }
 }
コード例 #10
0
 internal TimerEventSubscription Dequeue()
 {
     lock (this.locker)
     {
         TimerEventSubscription subscription = this.queue.Dequeue();
         if (subscription != null)
         {
             WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "TimerEventSubscriptionQueue: {0} Dequeue Timer {1} for {2} ", new object[] { this.instanceId, subscription.SubscriptionId, subscription.ExpiresAt });
         }
         return(subscription);
     }
 }
コード例 #11
0
		public void TestCollection ()
		{
			TimerEventSubscriptionCollection col;

        		// There is no public constructor for TimerEventSubscriptionCollection
			col = (TimerEventSubscriptionCollection) Activator.CreateInstance
				(typeof (TimerEventSubscriptionCollection),
				BindingFlags.Instance |BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public,
				null, null, null);

			TimerEventSubscription event1 = new TimerEventSubscription (Guid.NewGuid (),
				new DateTime (2006, 07, 30));

			TimerEventSubscription event2 = new TimerEventSubscription (Guid.NewGuid (),
				new DateTime (2006, 07, 28));

			TimerEventSubscription event3 = new TimerEventSubscription (Guid.NewGuid (),
				new DateTime (2006, 08, 28));

			TimerEventSubscription event4 = new TimerEventSubscription (Guid.NewGuid (),
				new DateTime (2007, 08, 28));

			TimerEventSubscription event5 = new TimerEventSubscription (Guid.NewGuid (),
				new DateTime (2006, 05, 28));

			TimerEventSubscription event6 = new TimerEventSubscription (Guid.NewGuid (),
				new DateTime (2008, 02, 28));

			TimerEventSubscription event7 = new TimerEventSubscription (Guid.NewGuid (),
				new DateTime (2005, 05, 28));

			col.Add (event1);
			col.Add (event2);
			col.Add (event3);
			col.Add (event4);
			col.Add (event5);
			col.Add (event6);
			col.Add (event7);

			Assert.AreEqual (event7.ExpiresAt, col.Peek ().ExpiresAt, "C1#1");
			col.Remove (col.Peek ());
			Assert.AreEqual (event5.ExpiresAt, col.Peek ().ExpiresAt, "C1#2");
			col.Remove (col.Peek ());
			Assert.AreEqual (event2.ExpiresAt, col.Peek ().ExpiresAt, "C1#3");
			col.Remove (col.Peek ());
			Assert.AreEqual (event1.ExpiresAt, col.Peek ().ExpiresAt, "C1#4");
			col.Remove (col.Peek ());
			Assert.AreEqual (event3.ExpiresAt, col.Peek ().ExpiresAt, "C1#5");
			col.Remove (col.Peek ());
			Assert.AreEqual (event4.ExpiresAt, col.Peek ().ExpiresAt, "C1#6");

		}
コード例 #12
0
 public void CopyTo(Array array, int index)
 {
     TimerEventSubscription[] subscriptionArray = null;
     lock (this.locker)
     {
         subscriptionArray = new TimerEventSubscription[this.queue.Count];
         this.queue.Values.CopyTo(subscriptionArray, 0);
     }
     if (subscriptionArray != null)
     {
         subscriptionArray.CopyTo(array, index);
     }
 }
コード例 #13
0
 internal void SuspendDelivery()
 {
     lock (this.locker)
     {
         WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "TimerEventSubscriptionQueue: {0} Suspend", new object[] { this.instanceId });
         WorkflowSchedulerService service      = this.executor.GetService(typeof(WorkflowSchedulerService)) as WorkflowSchedulerService;
         TimerEventSubscription   subscription = this.queue.Peek();
         if (subscription != null)
         {
             service.Cancel(subscription.SubscriptionId);
         }
     }
 }
コード例 #14
0
 internal void ResumeDelivery()
 {
     lock (this.locker)
     {
         WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "TimerEventSubscriptionQueue: {0} Resume", new object[] { this.instanceId });
         WorkflowSchedulerService service      = this.executor.GetService(typeof(WorkflowSchedulerService)) as WorkflowSchedulerService;
         TimerEventSubscription   subscription = this.queue.Peek();
         if (subscription != null)
         {
             service.Schedule(this.executor.ProcessTimersCallback, subscription.WorkflowInstanceId, subscription.ExpiresAt, subscription.SubscriptionId);
         }
     }
 }
 public void CopyTo(Array array, int index)
 {
     TimerEventSubscription[] subscriptionArray = null;
     lock (this.locker)
     {
         subscriptionArray = new TimerEventSubscription[this.queue.Count];
         this.queue.Values.CopyTo(subscriptionArray, 0);
     }
     if (subscriptionArray != null)
     {
         subscriptionArray.CopyTo(array, index);
     }
 }
コード例 #16
0
 public void CopyTo(Array array, int index)
 {
     TimerEventSubscription[] tes = null;
     lock (locker)
     {
         tes = new TimerEventSubscription[queue.Count];
         queue.Values.CopyTo(tes, 0);
     }
     if (tes != null)
     {
         tes.CopyTo(array, index);
     }
 }
コード例 #17
0
ファイル: WorkflowProcessor.cs プロジェクト: stanasse/olive
        // This is called by the timer to process the TimeEventSubcriptionCollection
        static private void TimerSubscriptionsCallback(object state)
        {
            WorkflowInstance wi = (WorkflowInstance)state;

            if (wi.TimerEventSubscriptionCollection.Count == 0)
            {
                return;
            }

            if (wi.TimerEventSubscriptionCollection.Peek().ExpiresAt > DateTime.UtcNow)
            {
                return;
            }

            TimerEventSubscription ti = wi.TimerEventSubscriptionCollection [0];

            // Event has arrived, send a message to the queue
            wi.EnqueueItem(ti.QueueName, ti, null, null);
            wi.TimerEventSubscriptionCollection.Remove(ti);
        }
コード例 #18
0
ファイル: Activity.cs プロジェクト: alesliehughes/olive
		protected IComparable SetTimer (ActivityExecutionContext executionContext, DateTime expiresAt)
		{
		#if RUNTIME_DEP
			TimerEventSubscription te;
			WorkflowQueue queue;

			te = new TimerEventSubscription (executionContext.ExecutionContextManager.Workflow.InstanceId,
				expiresAt);

			WorkflowQueuingService qService = executionContext.GetService <WorkflowQueuingService> ();
		    	queue = qService.CreateWorkflowQueue (te.QueueName, true);
		    	queue.QueueItemArrived += OnQueueTimerItemArrived;
			executionContext.ExecutionContextManager.Workflow.TimerEventSubscriptionCollection.Add (te);
			return te.QueueName;
		#else
			return null;
		#endif

		}
コード例 #19
0
 public void Remove(TimerEventSubscription item)
 {
     list.Remove(item);
 }
コード例 #20
0
 public void CopyTo(Array array, int index)
 {
     TimerEventSubscription[] tes = null;
     lock (locker)
     {
         tes = new TimerEventSubscription[queue.Count];
         queue.Values.CopyTo(tes, 0);
     }
     if (tes != null)
         tes.CopyTo(array, index);
 }
コード例 #21
0
 public void Remove(TimerEventSubscription item)
 {
     if (item == null)
         throw new ArgumentNullException("item");
     this.Remove(item.SubscriptionId);
 }
コード例 #22
0
		public void Remove (TimerEventSubscription item)
		{
			list.Remove (item);
		}