Ejemplo n.º 1
0
        // Interlal_Ad Job is called by all of the other add jobs. This migrates towards class based jobs now the apps more complex
        private void Internal_AddJob(BaseJob theJob, bool causeWakeup, bool allowQueue)
        {
            if (m_refuseAllNewTasks)
            {
                //Bilge.Log("Mex::Core::AddJob >> Shutdown has been called for WorkManager, yet new task was requested");
                //Bilge.Warning("Mex::Core::AddJob >> Refusing to queue task, Core Shutting Down -> Job refused was " + theJob.GetIdentifier());
                return;
            }

            if ((m_notificationJobsSuspended == true) && (theJob is Job_Notification))
            {
                //if ((jobId == JobList.Notify_KnownProcessUpdate) || (jobId == JobList.Notify_NewEventAdded) || (jobId == JobList.Notify_PurgeAllCompleted)) {
                //Bilge.Log("Mex::Core::AddJob -> Job Skipped, " + theJob.GetIdentifier() + " skipped as notifications are disabled.");
                return;
                //}
            }

            if (allowQueue)
            {
                // Asynch Work request
                m_jobQueue.Enqueue(theJob);
            }
            else
            {
                // Synchronous work request
                ProcessJob(theJob);
            }

            if (causeWakeup)
            {
                MexCore.TheCore.PokeCoreThread();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This will check the work queue for a job and then perform the next job on the queue
        /// </summary>
        internal void DoWork()
        {
            if (m_jobQueue.Count > 0)
            {
                // TODO : Error handling and simplify the dequeue mechanism

                BaseJob aJob = (BaseJob)m_jobQueue.Dequeue();
                ProcessJob(aJob);
            }
        }
Ejemplo n.º 3
0
        internal override JobVerificationResults VerifyOtherJobsOnStack(BaseJob alternative)
        {
            Job_ChangeTCPGathererState alt = alternative as Job_ChangeTCPGathererState;

            if (alt == null)
            {
                return(JobVerificationResults.None);
            }

            if (alt.m_changeStateToActivate == m_changeStateToActivate)
            {
                return(JobVerificationResults.CurrentJobRendersFutureJobRedundant);
            }
            else
            {
                return(JobVerificationResults.FutureJobRendersCurrentJobRedundant);
            }
        }
Ejemplo n.º 4
0
        internal override JobVerificationResults VerifyOtherJobsOnStack(BaseJob alternative)
        {
            Job_ActivateODSGatherer alt = alternative as Job_ActivateODSGatherer;

            if (alt == null)
            {
                return(JobVerificationResults.None);
            }                                                          // No impact.

            // Essentially if there is another one which is the same then remove the other one, if its different then remove this one, as there
            // is no point turning it on then immediately off etc.
            if (alt.m_activatethegatherer == m_activatethegatherer)
            {
                return(JobVerificationResults.CurrentJobRendersFutureJobRedundant);
            }
            else
            {
                return(JobVerificationResults.FutureJobRendersCurrentJobRedundant);
            }
        }
Ejemplo n.º 5
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);
        }
 internal override JobVerificationResults VerifyOtherJobsOnStack(BaseJob alternative)
 {
     return(JobVerificationResults.None);
 }
Ejemplo n.º 7
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
Ejemplo n.º 8
0
 internal void AddJob(BaseJob theJob, bool forceWakeup)
 {
     Internal_AddJob(theJob, forceWakeup, true);
 }
Ejemplo n.º 9
0
 internal void AddJob(BaseJob theJob)
 {
     Internal_AddJob(theJob, false, true);
 }