Beispiel #1
0
 /// <summary>
 /// Register an ant as worker in the task manager
 /// </summary>
 /// <param name="ant"></param>
 public void RegisterWorker(PowerAntClass ant)
 {
     if (!Worker.Contains(ant))
     {
         Worker.Add(ant);
         log.Debug($"Worker registered {ant.Id}");
     }
 }
Beispiel #2
0
        /// <summary>
        /// Unregister a (e.g. dead) worker and make
        /// sure that his remaining work is enqueued
        /// </summary>
        /// <param name="ant"></param>
        /// <param name="task"></param>
        public void UnregisterWorker(PowerAntClass ant, Task task = null)
        {
            if (Worker.Contains(ant))
            {
                if (task != null)
                {
                    collectorQ.Enqueue(task);
                }
                Worker.Remove(ant);

                log.Debug($"Worker unregistered {ant.Id}, job={task}");
            }
        }