Exemple #1
0
 public MicroThread(Scheduler scheduler, MicroThreadFlags flags = MicroThreadFlags.None)
 {
     Id = Interlocked.Increment(ref globalCounterId);
     Scheduler = scheduler;
     ScheduledLinkedListNode = new PriorityQueueNode<SchedulerEntry>(new SchedulerEntry(this));
     AllLinkedListNode = new LinkedListNode<MicroThread>(this);
     ScheduleMode = ScheduleMode.Last;
     Flags = flags;
     Tags = new PropertyContainer(this);
     cancellationTokenSource = new CancellationTokenSource();
 }
Exemple #2
0
        internal void Schedule(PriorityQueueNode<SchedulerEntry> schedulerEntry, ScheduleMode scheduleMode)
        {
            var nextCounter = SchedulerCounter++;
            if (scheduleMode == ScheduleMode.First)
                nextCounter = -nextCounter;

            schedulerEntry.Value.SchedulerCounter = nextCounter;

            scheduledEntries.Enqueue(schedulerEntry);
        }
Exemple #3
0
 // TODO: We will need a better API than exposing PriorityQueueNode<SchedulerEntry> before we can make this public.
 internal void Add(Action simpleAction, int priority = 0, object token = null)
 {
     var schedulerEntryNode = new PriorityQueueNode<SchedulerEntry>(new SchedulerEntry(simpleAction, priority) { Token = token });
     Schedule(schedulerEntryNode, ScheduleMode.Last);
 }