コード例 #1
0
ファイル: CPU.cs プロジェクト: AstRyou/All
 public bool visit(CPUProblem problem)
 {
     //if(problem.RequiredThreads <= threads)
     //{
     //    Console.WriteLine(model + " with " + threads + " solved: " + problem.Name + " and Reuired threads: " + problem.RequiredThreads);
     //    return true;
     //}
     //Console.WriteLine("*******************" + model + " with " + threads + " threads cant solve: " + problem.Name + " and Reuired threads: " + problem.RequiredThreads);
     return(problem.RequiredThreads <= threads);
 }
コード例 #2
0
 public virtual int?TrySolve(CPUProblem p)
 {
     if (threads >= p.RequiredThreads)
     {
         Console.WriteLine("Problem {0} - solved with CPU {1}", p.Name, model);
         return(p.Computation());
     }
     Console.WriteLine("Problem {0} - failed to solve with CPU {1}", p.Name, model);
     return(null);
 }
コード例 #3
0
ファイル: CPU.cs プロジェクト: WojciechKrawczyk/Visitor
 public int?Visit(CPUProblem cPUProblem)
 {
     if (this.threads >= cPUProblem.RequiredThreads)
     {
         System.Console.WriteLine($"{this.model} resolved the problem");
         return(cPUProblem.Computation());
     }
     System.Console.WriteLine($"{this.model} failed to resolve the problem");
     return(null);
 }
コード例 #4
0
ファイル: CPU.cs プロジェクト: chlebnymaciej/Design_Patterns
 public int?CanSolve(CPUProblem p)
 {
     if (p.RequiredThreads <= this.threads)
     {
         SolvingInfo.Solved(this.model, p.Name);
         return(p.Computation());
     }
     SolvingInfo.NotSolved(this.model, p.Name);
     return(null);
 }
コード例 #5
0
ファイル: GPU.cs プロジェクト: chlebnymaciej/Design_Patterns
 public int?CanSolve(CPUProblem p)
 {
     if (DidThermalThrottle())
     {
         SolvingInfo.NotSolved(this.model, p.Name);
         return(null);
     }
     SolvingInfo.Solved(this.model, p.Name);
     this.temperature += CPUProblemTemperatureMultiplier * p.RequiredThreads;
     return(p.Computation());
 }
コード例 #6
0
ファイル: GPU.cs プロジェクト: WojciechKrawczyk/Visitor
 public int?Visit(CPUProblem cPUProblem)
 {
     if (!DidThermalThrottle())
     {
         this.temperature += CPUProblemTemperatureMultiplier * cPUProblem.RequiredThreads;
         System.Console.WriteLine($"{this.model} resolved the problem");
         return(cPUProblem.Computation());
     }
     System.Console.WriteLine($"{this.model} failed to resolve the problem");
     return(null);
 }
コード例 #7
0
 public virtual int?TrySolve(CPUProblem p)
 {
     if (temperature <= MaxTemperature)
     {
         temperature += p.RequiredThreads * CPUProblemTemperatureMultiplier;
         DidThermalThrottle();
         Console.WriteLine("Problem {0} - solved with GPU {1}", p.Name, model);
         return(p.Computation());
     }
     Console.WriteLine("Problem {0} - failed to solve with GPU {1}", p.Name, model);
     return(null);
 }
コード例 #8
0
ファイル: GPU.cs プロジェクト: AstRyou/All
        public bool visit(CPUProblem problem)
        {
            //Console.WriteLine(model+ " with temperature: " + temperature + " and Maxtempeture: " + MaxTemperature);
            if (DidThermalThrottle())
            {
                return(false);
            }

            temperature += problem.RequiredThreads * CPUProblemTemperatureMultiplier;
            //  Console.WriteLine(model + " solved: "+nameof(CPUProblem)+" " +problem.Name +" RequiredThreads:"+ problem.RequiredThreads + " Current tempeture: " + temperature);
            return(true);
        }
コード例 #9
0
ファイル: CPU.cs プロジェクト: Vickers-Zhu/Design_Patterns
 public int?Solve(CPUProblem problem)
 {
     if (problem.RequiredThreads <= threads)
     {
         Console.WriteLine($"CPU {model} solve {problem.Name}");
         return(problem.RequiredThreads);
     }
     else
     {
         Console.WriteLine($"CPU {model} is without enough threads to solve {problem.Name}");
         return(null);
     }
 }
コード例 #10
0
ファイル: GPU.cs プロジェクト: Vickers-Zhu/Design_Patterns
 public int?Solve(CPUProblem problem)
 {
     if (temperature <= MaxTemperature)
     {
         temperature += problem.RequiredThreads * CPUProblemTemperatureMultiplier;
         Console.WriteLine($"GPU {model} solve {problem.Name}, temperature: {temperature}");
         return(temperature);
     }
     else
     {
         DidThermalThrottle();
         return(null);
     }
 }
コード例 #11
0
 public override int?Solve(CPUProblem problem)
 {
     Console.WriteLine($"Device {DeviceType} cannot solve {problem.Name}");
     return(null);
 }
コード例 #12
0
 public int?CanSolve(CPUProblem p)
 {
     SolvingInfo.NotSolved(this.model, p.Name);
     return(null);
 }
コード例 #13
0
 abstract public int?Solve(CPUProblem problem);
コード例 #14
0
 public bool visit(CPUProblem problem)
 {
     return(false);
 }
コード例 #15
0
 public virtual int?TrySolve(CPUProblem p)
 {
     Console.WriteLine("Problem {0} - failed to solve with {1} {2}", p.Name, DeviceType, model);
     return(null);
 }
コード例 #16
0
 public int?Visit(CPUProblem cPUProblem)
 {
     System.Console.WriteLine($"{this.model} failed to resolve the problem");
     return(null);
 }