def get_free_cores(threshold: float, cpu: Cpu, workload_map: Dict[str, Workload], cpu_usage: Dict[str, float]) -> List[Core]: return [ c for c in cpu.get_cores() if is_core_below_threshold(threshold, c, cpu_usage, workload_map) ]
def get_free_threads(self, cpu: Cpu, workload_map: Dict[str, Workload], cpu_usage: Dict[str, float] = None) -> List[Thread]: free_cores = [ c.get_threads() for c in cpu.get_cores() if len(c.get_empty_threads()) == 2 ] if len(free_cores) == 0: return [] return reduce(list.__add__, free_cores)