pop method
Pops the next available job from the queue atomically.
Implementations MUST guarantee that no two workers can receive
the same job (distributed lock / atomic dequeue).
Returns null if the queue is empty or no jobs are available.
Implementation
@override
Future<Job?> pop([String queue = 'default']) async {
final q = _getQueue(queue);
if (q.isEmpty) return null;
// Find the first available job (respects delayed/retry scheduling)
for (var i = 0; i < q.length; i++) {
final job = q.removeFirst();
if (job.isAvailable) return job;
// Not yet available, put it back at the end
q.add(job);
}
return null; // All jobs are delayed
}