Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #4
0
 protected void AutoGenerateJobId(CM_Job job)
 {
     job.id = uniqueGeneratedID;
 }
Beispiel #5
0
        protected virtual CM_Job MakeJob(CM_Job job)
        {
            job.NotifyOnJobComplete(HandlejobComplete);

            return(job);
        }
Beispiel #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));
 }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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));
 }
Beispiel #11
0
 private void RemoveJobFromQueue(CM_Job job)
 {
     job.RemoveNotifyOnJobComplete(HandlejobComplete);
     _completedJobs.Add(job);
     _jobQueue.Dequeue();
 }
Beispiel #12
0
 private void AddJobToQueue(CM_Job job)
 {
     _jobQueue.Enqueue(job);
 }
Beispiel #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;
 }