icanzilb / TaskQueue

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

Queue not running #19

Open sameerKLT opened 7 years ago

sameerKLT commented 7 years ago

The following is the setup and the issue I am running into:

let queue = TaskQueue()

func init() {
     downloadStuff()
}

func downloadStuff() {
   queue.tasks += {[weak queue] result, next in

       myTask(completion: { success in
          if success {
               next(nil)
          }
          else {
             print("error out")
          }
       }

   }

   queue.run() {
       print("completed")
   }
}

func unauthorizedUse() {
     queue.removeAll()
}

func authorizedUse() {
     downloadStuff()
}
icanzilb commented 7 years ago

hey, in general the taskqueue class was meant to be a one-off object, I personally haven't tested situations where it has a long life cycle and is being re-used all the time. if you figure something out - make a PR 👍