コード例 #1
0
    public override void AdvanceTime(TimeSpan timeToSimulate)
    {
        List <int> toRemove = new List <int> ();

        // First check if some new task needs to be added
        foreach (KeyValuePair <int, TimeSpan> req in firstFlowArrivalTimePerRequest)
        {
            // If time expired, send partial results, or if all flows received
            TimeSpan beginTime = GlobalVariables.requests[req.Key].beginSec;
            TimeSpan w         = defaultWaitTime;
            //Console.Error.WriteLine(GlobalVariables.currentTime + ": " + (beginTime + w));
            if ((GlobalVariables.currentTime >= beginTime + w) ||
                (numFlowsPerRequest [req.Key] == fanout))
            {
                //GlobalVariables.
                //Console.Error.WriteLine("Timed out: " + w);
                //Console.Error.WriteLine(GlobalVariables.currentTime + ": MLA adding task");
                GlobalVariables.requests [req.Key].numFlowsCompleted += numFlowsPerRequest [req.Key];
                //Console.Error.WriteLine(layer + " " + req.Key + " " + id);
                InsertTask(GlobalVariables.mlaTasks[layer][req.Key][id]);
                toRemove.Add(req.Key);
                isRequestProcessed [req.Key] = true;
            }
        }
        foreach (int i in toRemove)
        {
            numFlowsPerRequest.Remove(i);
            firstFlowArrivalTimePerRequest.Remove(i);
        }

        List <Task> finished = new List <Task> ();

        foreach (Task t in tasksToSchedule)
        {
            t.progressSec += timeToSimulate;
            //Console.Error.WriteLine(GlobalVariables.currentTime + ": Progress " + t.progressSec);
            if (t.progressSec >= t.processingTimeSec)
            {
                hla.InsertFlow(Flow.CreateNewFlow(t,
                                                  informationContentPerRequest [t.requestId]));
                finished.Add(t);
            }
        }
        foreach (Task t in finished)
        {
            tasksToSchedule.Remove(t);
        }
    }
コード例 #2
0
    public override void AdvanceTime(TimeSpan timeToSimulate)
    {
        List <Task> finished = new List <Task> ();

        foreach (Task t in tasksToSchedule)
        {
            t.progressSec += timeToSimulate;
            if (t.progressSec >= t.processingTimeSec)
            {
                mla.InsertFlow(Flow.CreateNewFlow(t, 1.0));

                finished.Add(t);
            }
        }
        foreach (Task toRemove in finished)
        {
            tasksToSchedule.Remove(toRemove);
        }
    }