Exemplo n.º 1
0
    public TaskManager()
    {
        this.m_TaskList    = new List <Task>();
        this.m_NewOpenTask = new List <Task>();
        this.m_RemoveTask  = new List <Task>();

        this.m_Sequencer = new TaskSequencer(this.m_TaskList);
    }
Exemplo n.º 2
0
        //TODO figure out why this is not used
        //public Task FindNearestAssignedTask(Task fromTask)
        //{
        //    int minDistance = Int32.MaxValue;
        //    Task minTask = null;
        //    foreach (Task task in _tasks)
        //    {
        //        // assigned?
        //        if (_taskDistributedWorker[task.Id] != -1 && fromTask.Id != task.Id)
        //        {
        //            //int distance = task.DistanceTo(fromTask);
        //            int cost = task.CostTo(fromTask);
        //            if (cost < minDistance)
        //            {
        //                minDistance = cost;
        //                minTask = task;
        //            }
        //        }
        //    }
        //    return minTask;
        //}
        private void Configure(Configuration config)
        {
            _rand = new Random(config.RandomSeed);

            ConfigureTasks(config);

            _workers = config.Workers;
            _distributor = config.Distributor;

            _taskDistributedWorker = new int[_tasks.Count];
            _lastTaskDistributedWorker = new int[_tasks.Count];
            _sequencers = new TaskSequencer[_workers.Count];
            _distributedTasks = new List<Task>[_workers.Count];
            Sequences = new List<TaskSequence>(_workers.Count);

            for (int t = 0; t < _workers.Count; t++)
            {
                _distributedTasks[t] = new List<Task>(_tasks.Count);
                _sequencers[t] = new TaskSequencer(_tasks.Count);
                Sequences.Add(null);
            }

            for (int t = 0; t < _tasks.Count; t++)
            {
                _lastTaskDistributedWorker[t] = -1;
            }
        }