int getAvailableWorkerId()

Source

int getAvailableWorkerId() {
  var ids = _workCounts.keys.toList();
  ids.sort((a, b) => _workCounts[a].compareTo(_workCounts[b]));
  var best = ids.first;
  _workCounts[best] = _workCounts[best] + 1;
  return best;
}