Exemple #1
0
        /// <summary>
        /// Enqueues the specified job.
        /// </summary>
        /// <param name="job">Job.</param>
        public CM_JobQueue Enqueue(CM_Job job)
        {
            job.NotifyOnJobComplete(HandlejobComplete);

            AddJobToQueue(job);

            if (_continousRunning && _jobQueue.Count == 1)
            {
                _jobQueue.Peek().Start();
            }

            return(this);
        }
Exemple #2
0
        protected virtual CM_Job MakeJob(string id, IEnumerator routine, bool addListenerToOnComplete = true)
        {
            var job = CM_Job.Make(routine);

            job.id = (id.IsNullOrEmpty()) ? uniqueGeneratedID : id;

            if (addListenerToOnComplete)
            {
                job.NotifyOnJobComplete(HandlejobComplete);
            }

            return(job);
        }
Exemple #3
0
        /// <summary>
        /// Adds a job to the job manager.
        /// </summary>
        /// <returns>The job.</returns>
        /// <param name="job">Job.</param>
        public CM_JobManager AddJob(CM_Job job)
        {
            if (job.id.IsNullOrEmpty())
            {
                AutoGenerateJobId(job);
            }

            if (!_ownedJobs.ContainsKey(job.id))
            {
                _ownedJobs.Add(job.id, job);

                OnJobAdded(new CM_JobManagerJobEditedEventArgs(_ownedJobs, job));
            }

            return(this);
        }
Exemple #4
0
 protected void AutoGenerateJobId(CM_Job job)
 {
     job.id = uniqueGeneratedID;
 }
Exemple #5
0
        protected virtual CM_Job MakeJob(CM_Job job)
        {
            job.NotifyOnJobComplete(HandlejobComplete);

            return(job);
        }
Exemple #6
0
 /// <summary>
 /// Determines whether the specified job is executing.
 /// </summary>
 /// <returns><c>true</c> if the job is currently running; otherwise, <c>false</c>.</returns>
 /// <param name="job">Job.</param>
 public bool IsRunning(CM_Job job)
 {
     return(IsRunning(job.id));
 }
Exemple #7
0
        /// <summary>
        /// Resumes the specified coroutine if owned by this instance of job manager. Job is searched using job id.
        /// </summary>
        /// <returns>The job manager.</returns>
        /// <param name="job">Job.</param>
        public CM_JobManager ResumeCoroutine(CM_Job job)
        {
            ResumeCoroutine(job.id);

            return(this);
        }
Exemple #8
0
        /// <summary>
        /// Pauses the specified coroutine if owned by this instance of job manager. Job is searched using job id.
        /// </summary>
        /// <returns>The job manager.</returns>
        /// <param name="job">Job.</param>
        public CM_JobManager PauseCoroutine(CM_Job job)
        {
            PauseCoroutine(job.id);

            return(this);
        }
Exemple #9
0
        /// <summary>
        /// Stops the specified coroutine if owned by this instance of job manager. Job is searched using job id.
        /// </summary>
        /// <returns>The job manager.</returns>
        /// <param name="job">Job.</param>
        public CM_JobManager StopCoroutine(CM_Job job)
        {
            StopCoroutine(job.id);

            return(this);
        }
Exemple #10
0
 /// <summary>
 /// Removes the job if owned by this instance of job manager.
 /// </summary>
 /// <returns>The job manager.</returns>
 /// <param name="job">Job.</param>
 public CM_JobManager RemoveJob(CM_Job job)
 {
     return(RemoveJob(job.id));
 }
Exemple #11
0
 private void RemoveJobFromQueue(CM_Job job)
 {
     job.RemoveNotifyOnJobComplete(HandlejobComplete);
     _completedJobs.Add(job);
     _jobQueue.Dequeue();
 }
Exemple #12
0
 private void AddJobToQueue(CM_Job job)
 {
     _jobQueue.Enqueue(job);
 }
Exemple #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CM_JobManagerJobEditedEventArgs"/> class.
 /// </summary>
 /// <param name="ownedJobs">Owned jobs.</param>
 /// <param name="jobEdited">Job edited.</param>
 public CM_JobManagerJobEditedEventArgs(Dictionary <string, CM_Job> ownedJobs, CM_Job jobEdited)
 {
     this.otherArgs = new CM_JobManagerEventArgs(ownedJobs);
     this.jobEdited = jobEdited;
 }