Beispiel #1
0
        public FCgRoutine Start(FECgCoroutineSchedule schedule, IEnumerator fiber)
        {
            FCgCoroutinePayload payload = AllocatePayload();

            payload.Schedule = schedule;
            payload.Fiber    = fiber;

            return(Start(payload));
        }
Beispiel #2
0
        public void Prep(FCgRoutine r, FCgCoroutinePayload payload)
        {
            r.Start(payload.Fiber, payload.Stop, payload.Owner, payload.OwnerName, payload.StartTime, payload.Add, payload.Remove, payload.RoutineType);
            r.State = ECgRoutineState.Allocating;

            LogTransaction(ECgCoroutineSchedulerCached.Str.Prep, ECgCoroutineTransaction.Allocate, r);

            payload.Reset();
        }
Beispiel #3
0
        public FCgRoutine Allocate(FCgCoroutinePayload payload)
        {
            FECgCoroutineSchedule schedule = payload.Schedule;

            FCgRoutine r = Allocate_Internal(schedule);

            r.Start(payload.Fiber, payload.Stop, payload.Owner, payload.OwnerName, payload.StartTime, payload.Add, payload.Remove, payload.RoutineType);
            r.State = ECgRoutineState.Allocating;

            LogTransaction(ECgCoroutineSchedulerCached.Str.Allocate, ECgCoroutineTransaction.Allocate, r);

            payload.Reset();

            return(r);
        }
Beispiel #4
0
        public FCgCoroutinePayload AllocatePayload()
        {
            for (int i = 0; i < POOL_SIZE; ++i)
            {
                PayloadIndex = (PayloadIndex + 1) % POOL_SIZE;

                FCgCoroutinePayload p = Payloads[PayloadIndex];

                if (!p.bAllocated)
                {
                    return(p);
                }
            }
            Debug.LogWarning("FCgCoroutineScheduler.AllocatePayload: No free Payloads. Look for Runaway Coroutines or consider raising the pool size.");
            return(null);
        }
Beispiel #5
0
        public FCgRoutine Start(FCgCoroutinePayload payload)
        {
            FECgCoroutineSchedule schedule = payload.Schedule;

            FCgRoutine r = Allocate_Internal(schedule);

            if (r == null)
            {
                payload.Reset();
                return(null);
            }

            // If NO Head, Make r the Head
            if (Heads[schedule] == null)
            {
                Heads[schedule] = r;
                Tails[schedule] = r;
            }
            // Add r end of the list, Make r the Tail
            else
            {
                FCgRoutine tail = Tails[schedule];
                tail.Next       = r;
                r.Prev          = tail;
                Tails[schedule] = r;
            }

            RoutinesRunning[schedule].Add(r);

            // TODO: get Time from Manager_Time
            r.Start(payload.Fiber, payload.Stop, payload.Owner, payload.OwnerName, payload.StartTime, payload.Add, payload.Remove, payload.RoutineType);
            r.State = ECgRoutineState.Running;

            LogTransaction(ECgCoroutineSchedulerCached.Str.Start, ECgCoroutineTransaction.Start, r);

            payload.Reset();
            r.Run(0.0f);
            return(r);
        }