While sorting machines by load, the load of a machine (machine->currentJobs) can be changed by other threads. If that happens, the comparator is no longer a proper ordering, in which case std::sort() can segfault. So we now make a copy of currentJobs before sorting.
ODCBSLFGJGNOMKPZV6TS2SVTQMVUXR3K2BQJHNAJHTR4HECDBBNAC /* Bail out when there are no slots left. */std::vector<Machine::ptr> machinesSorted;
/* Copy the currentJobs field of each machine. This isnecessary to ensure that the sort comparator below is aordering. std::sort() can segfault if it isn't. */struct MachineInfo{Machine::ptr machine;unsigned int currentJobs;};std::vector<MachineInfo> machinesSorted;
a->speedFactor != b->speedFactor ? a->speedFactor > b->speedFactor :a->currentJobs > b->currentJobs;
a.machine->speedFactor != b.machine->speedFactor ? a.machine->speedFactor > b.machine->speedFactor :a.currentJobs > b.currentJobs;