AddFunc adds new instance to the queue with a custom runnable function, the queue is blocked until the function exits.
(id any, fn func())
| 41 | // AddFunc adds new instance to the queue with a custom runnable function, |
| 42 | // the queue is blocked until the function exits. |
| 43 | func (q *UniqueQueue) AddFunc(id any, fn func()) { |
| 44 | if q.Exist(id) { |
| 45 | return |
| 46 | } |
| 47 | |
| 48 | idStr := com.ToStr(id) |
| 49 | q.table.Lock() |
| 50 | q.table.pool[idStr] = true |
| 51 | if fn != nil { |
| 52 | fn() |
| 53 | } |
| 54 | q.table.Unlock() |
| 55 | q.queue <- idStr |
| 56 | } |
| 57 | |
| 58 | // Add adds new instance to the queue. |
| 59 | func (q *UniqueQueue) Add(id any) { |
no test coverage detected