예제 #1
0
        internal void AddJob(BaseJob theJob, bool forceWakeup, bool onlyIfNotAlreadyPresent)
        {
            if (!onlyIfNotAlreadyPresent)
            {
                Internal_AddJob(theJob, forceWakeup, true);
                return;
            }
            foreach (BaseJob bj in m_jobQueue)
            {
                if (bj.JobDeleted)
                {
                    continue;
                }

                JobVerificationResults jrv = theJob.VerifyOtherJobsOnStack(bj);
                switch (jrv)
                {
                case JobVerificationResults.CurrentJobRendersFutureJobRedundant:
                    bj.JobDeleted = true;
                    //Bilge.VerboseLog("Destroying an exsiting refresh job and placing this one on the queue");
                    Internal_AddJob(theJob, forceWakeup, true);
                    return;

                case JobVerificationResults.FutureJobRendersCurrentJobRedundant:
                    //Bilge.VerboseLog("Job destroyed as one already in the queue.");
                    return;

                case JobVerificationResults.FutureJobModifiedSuchThatCurrentIsRedundant:
                    //Bilge.VerboseLog("Job destroyed as one already in the queue.");
                    return;
                }
            }

            // If the queue is empty just place it on.
            Internal_AddJob(theJob, forceWakeup, true);
        }
예제 #2
0
        /// <summary>
        /// This will perform the action specified by a particular job and parameter.  This method understands all of the elements of the system
        /// required to perform the operations that can be listed as a job.  As a result this method is fairly crucial to the operation of mex.
        /// </summary>
        /// <param name="theJob"></param>
        internal void ProcessJob(BaseJob theJob)
        {
            //Bilge.Log("PrimaryWorkManager::ProcessJob -> called for Job (" + theJob.GetIdentifier() + ")");
            if (m_refuseAllNewTasks)
            {
                //Bilge.Warning("All new tasks being refused as shutdown has been called.  No new work should be being requested");
                return;
            }

            bool notificaitonSuspensionRequired = false;

            foreach (BaseJob bj in m_jobQueue)
            {
                if (!bj.JobDeleted)
                {
                    JobVerificationResults result = theJob.VerifyOtherJobsOnStack(bj);

                    switch (result)
                    {
                    case JobVerificationResults.CurrentJobRendersFutureJobRedundant:
                        bj.JobDeleted = true;
                        break;

                    case JobVerificationResults.FutureJobRendersCurrentJobRedundant:
                        theJob.JobDeleted = true;
                        break;

                    case JobVerificationResults.FutureJobModifiedSuchThatCurrentIsRedundant:
                        theJob.JobDeleted = true;
                        break;
                    }
                }
            }

            if (theJob.JobDeleted)
            {
                //Bilge.VerboseLog("Job " + theJob.GetIdentifier() + " has been deleted, efficiency!");
                return;
            }

            if (!theJob.InitialiseJob(out notificaitonSuspensionRequired))
            {
            }

            if (notificaitonSuspensionRequired)
            {
                SuspendNotificationJobs();

                try {
                    theJob.ExecuteJob();
                } finally {
                    ResumeNotificationJobs();
                }
            }
            else
            {
                theJob.ExecuteJob();
            }

            theJob.PerformPostJob();
        } // End PrimaryWorkManager::ProcessJob