func (cl *ConfigList) Remove(taskID int64) bool {
	cl.cond.L.Lock()
	defer cl.cond.L.Unlock()
	element, ok := cl.taskIDMap[taskID]
	if !ok {
		return false
	}
	delete(cl.taskIDMap, taskID)
	cl.nodes.Remove(element)
	return true
}
Remove removes a task from the list given its task ID. Returns true if a task
is successfully removed, false if the task ID did not exist.
package config
import (
	"container/list"
	"context"
	"sync"
	"time"
)
type ConfigList struct {
	cond      *sync.Cond
	taskIDMap map[int64]*list.Element
	nodes     list.List
	lastID int64
}
func NewConfigList() *ConfigList {
	return &ConfigList{
		cond:      sync.NewCond(new(sync.Mutex)),
		taskIDMap: make(map[int64]*list.Element),
	}
}
func (cl *ConfigList) Push(cfg *Config) {
	id := time.Now().UnixNano()
	cl.cond.L.Lock()
	defer cl.cond.L.Unlock()
	if id <= cl.lastID {
		id = cl.lastID + 1
	}
	cfg.TaskID = id
	cl.lastID = id
	cl.taskIDMap[id] = cl.nodes.PushBack(cfg)
	cl.cond.Broadcast()
}
func (cl *ConfigList) Pop(ctx context.Context) (*Config, error) {
	res := make(chan *Config)
	go func() {
		cl.cond.L.Lock()
		defer cl.cond.L.Unlock()
		for {
			if front := cl.nodes.Front(); front != nil {
				cfg := front.Value.(*Config)
				delete(cl.taskIDMap, cfg.TaskID)
				cl.nodes.Remove(front)
				res <- cfg
				break
			}
			cl.cond.Wait()
		}
	}()
	select {
	case cfg := <-res:
		return cfg, nil
	case <-ctx.Done():
		return nil, ctx.Err()
	}
}