Fetch the repository succeeded.
package rtool
import (
"fmt"
"sync"
"time"
)
type AccUniqueIdQueue struct {
lock sync.Mutex
IndexID int64
QueueList []string
}
func NewUniqueIdQueue() *AccUniqueIdQueue {
return &AccUniqueIdQueue{
lock: sync.Mutex{},
IndexID: time.Now().UnixNano(),
QueueList: make([]string, 0),
}
}
func (q *AccUniqueIdQueue) RPush(uniqueID string) {
q.lock.Lock()
defer q.lock.Unlock()
q.QueueList = append(q.QueueList, uniqueID)
}
func (q *AccUniqueIdQueue) LPush(uniqueID string) {
q.lock.Lock()
defer q.lock.Unlock()
q.QueueList = append([]string{uniqueID}, q.QueueList...)
}
func (q *AccUniqueIdQueue) AutoUniqueID() string {
q.lock.Lock()
defer q.lock.Unlock()
if len(q.QueueList) <= 0 {
q.IndexID++
rt := fmt.Sprint(q.IndexID)
return rt
}
rt := q.QueueList[0]
q.QueueList = q.QueueList[1:]
return rt
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。