DRY operation for pqueue, queue and alert.