Example #1
0
 internal AsyncPathWork(IWorkItemCollection gameJobs, ICPULoad budget)
 {
     Jobs        = gameJobs ?? throw new ArgumentNullException(nameof(gameJobs));
     this.budget = budget;
     runtime     = 1L;
     time        = new Stopwatch();
 }
Example #2
0
 internal PathProbeJobManager()
 {
     budget       = null;
     onPathDone   = new ManualResetEvent(false);
     running      = false;
     totalRuntime = 0L;
 }
    public static void Start(ICPULoad cpuLoad)
    {
        Node value = nodes[cpuLoad];

        value.start    = stopwatch.ElapsedTicks;
        nodes[cpuLoad] = value;
    }
Example #4
0
        /// <summary>
        /// Marks the CPULoad object that will be tracked by the next RunAsync call.
        /// </summary>
        /// <param name="group">The CPULoad object to use for tracking.</param>
        public static void SetCPUBudget(ICPULoad group)
        {
            var inst = Instance;

            if (inst != null)
            {
                inst.budget = group;
            }
        }
 public static void AddRoot(ICPULoad root)
 {
     nodes.Add(root, new Node
     {
         load                 = root,
         children             = new List <Node>(),
         frameTime            = root.GetEstimatedFrameTime(),
         loadBalanceThreshold = TuningData <Tuning> .Get().defaultLoadBalanceThreshold
     });
 }
    public static void End(ICPULoad cpuLoad)
    {
        Node  node = nodes[cpuLoad];
        float num  = node.frameTime - ComputeDuration(node.start);

        if (node.loadBalanceThreshold < Math.Abs(num))
        {
            Balance(cpuLoad, num);
        }
    }
    public static void AddChild(ICPULoad parent, ICPULoad child, float loadBalanceThreshold)
    {
        Node node = default(Node);

        node.load                 = child;
        node.children             = new List <Node>();
        node.frameTime            = child.GetEstimatedFrameTime();
        node.loadBalanceThreshold = loadBalanceThreshold;
        Node node2 = node;

        nodes.Add(child, node2);
        node = nodes[parent];
        node.children.Add(node2);
    }
    public static void FinalizeChildren(ICPULoad parent)
    {
        Node        node     = nodes[parent];
        Node        node2    = nodes[parent];
        List <Node> children = node2.children;
        float       num      = 0f;

        foreach (Node item in children)
        {
            Node current = item;
            FinalizeChildren(current.load);
            num += current.frameTime;
        }
        for (int i = 0; i != children.Count; i++)
        {
            Node value = children[i];
            value.frameTime = node.frameTime * (value.frameTime / num);
            children[i]     = value;
        }
    }
    public static void Balance(ICPULoad cpuLoad, float frameTimeDelta)
    {
        Node        node     = nodes[cpuLoad];
        List <Node> children = node.children;

        if (children.Count == 0)
        {
            if (node.load.AdjustLoad(node.frameTime, frameTimeDelta))
            {
                node.frameTime += frameTimeDelta;
            }
        }
        else
        {
            for (int i = 0; i != children.Count; i++)
            {
                Node  value           = children[i];
                float num             = value.frameTime / node.frameTime;
                float frameTimeDelta2 = frameTimeDelta * num;
                Balance(value.load, frameTimeDelta2);
                children[i] = value;
            }
        }
    }
Example #10
0
 public void Dispose()
 {
     onPathDone.Dispose();
     budget = null;
 }
 public static void AddChild(ICPULoad parent, ICPULoad child)
 {
     AddChild(parent, child, TuningData <Tuning> .Get().defaultLoadBalanceThreshold);
 }