Esempio n. 1
0
 public void PerformLockedModuleOperation(Action action)
 {
     GraphLock.EnterWriteLock();
     try
     {
         action();
     }
     finally
     {
         GraphLock.ExitWriteLock();
     }
 }
        public void Execute(JobCo[] jobs, int nbDevices)
        {
            Init(jobs);
            currentDevices = new Device <JobCo> [nbDevices];


            for (int i = 0; i < nbDevices; i++)
            {
                currentDevices[i] = new Device <JobCo>();
            }

            Device <JobCo>[] trOrder = currentDevices.OrderBy(j => j.TimeReady).ToArray();

            GraphLock G = new GraphLock(jobs);
            JobCo     higher;

            while ((higher = G.GetHigherOutDegreeOnTime(trOrder[0].TimeReady)) != null)
            {
                trOrder[0].AddJob(higher);
                onTime.Add(higher);
                G.ExecuteJob(higher);

                int i = 0;
                while (i < trOrder.Length - 1 && trOrder[i].TimeReady > trOrder[i + 1].TimeReady)
                {
                    trOrder.Swap(i, i + 1);
                    i++;
                }
            }

            late = G.GetAllLeftJobs();
            foreach (var jobCo in late)
            {
                trOrder[0].AddJob(jobCo);

                int i = 0;
                while (i < trOrder.Length - 1 && trOrder[i].TimeReady > trOrder[i + 1].TimeReady)
                {
                    trOrder.Swap(i, i + 1);
                    i++;
                }
            }
        }