icanzilb / TaskQueue

A Task Queue Class developed in Swift (by Marin Todorov)
MIT License
682 stars 74 forks source link

When do I use queue.run()? #7

Closed timigod closed 8 years ago

timigod commented 9 years ago

I'm not sure if this is an actual issue but I was wondering. When is the right time to call .run() on a queue? In your Readme, you always called it after you've added all the tasks you wanted to add. Is it possible to call .run() say in a class initialiser and keep adding tasks to it AFTER. So that it just keeps processing tasks as they come (one after the other)?

ghost commented 8 years ago

I can help... Define as many tasks as you want and then make a call to run()

queue.tasks += { task 1}
queue.tasks += { task 2}
queue.tasks += { task 3}
queue.tasks += { task 4}
queue.run() <<<<<<
icanzilb commented 8 years ago

hey @timigod - the queue runs until it has tasks to run, once it runs out of tasks it destroys itself...