A Multi-safe Delay queue by Golang.
typeTaskstruct {
IDint
}
// create a delay queue with cap 3q:=NewDelayQueue(3)
// add a Task to queue which should run after 10 seconds laterq.Offer(Task{ID: 1}, time.Now().Add(10*time.Second))
// run a goroutine to deal timer checkgoq.Poll()
// get ready element from delay queueele:=<-q.Cfmt.Println(ele) // Task{ID: 1}// stop go q.Poll(), you can run queue by call q.Poll() then.q.Stop()