Async::Queue is used to process tasks with the specified concurrency. The tasks given to Async::Queue are processed in parallel with its worker routine up to the concurrency level. If more tasks arrive at the Async::Queue object, those tasks will wait for currently running tasks to finish. When a task is finished, one of the waiting tasks starts to be processed in first-in-first-out (FIFO) order.

You can initialize the attributes in new() method. You can get and set the attributes of an Async::Queue object via their accessor methods (See "OBJECT METHODS").

Note that you cannot set any attribute listed here while there is a task running in the Async::Queue object. This is because changing the attributes during task execution is very confusing and leads to unpredictable behavior. So if you want to set an attribute, make sure there is no task running (running() method can be useful).

$callback is a callback subroutine reference that worker must call when the task is finished. $callback can take any list of arguments, which will be passed to the $finish_callback given to the push() method (See "OBJECT METHODS").

empty attribute is a subroutine reference that is called when the last task from the queue is given to the worker. This means there is no task waiting in the Async::Queue object.

If the Async::Queue object is not saturated, empty subroutine is called every time a task is pushed. This is because every pushed task goes into the queue first even if the Async::Queue object can process the task immediately.

Pushes a task into the Async::Queue object. The argument $task is mandatory, while $finish_callback is optional.

$task is a task that the worker will process. It will be given as the $task argument to the worker subroutine.

$finish_callback is a subroutine reference that will be called when the worker finishes processing the task. The arguments for $finish_callback (@results) are the arguments for the $callback subroutine reference in the worker subroutine.

This example uses AnyEvent::HTTP to send HTTP GET requests for multiple URLs simultaneously. While simultaneous requests dramatically improve efficiency, it may overload the client host and/or the network.

This is where Async::Queue comes in handy. With Async::Queue you can control the concurrency level of the HTTP sessions (in this case, up to three).