Function for allocating a worker.