mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-12-12 10:50:25 +08:00
feat: 新增数据库类型 mariadb, 分别为 mysql 和 mariadb 设置不同的数据库备份与恢复程序路径 (#81)
This commit is contained in:
@@ -57,13 +57,6 @@ func (s *DelayQueue[T]) TryDequeue() (T, bool) {
|
||||
return s.zero, false
|
||||
}
|
||||
|
||||
func (s *DelayQueue[T]) TryEnqueue(val T) bool {
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
|
||||
return s.enqueue(val)
|
||||
}
|
||||
|
||||
func (s *DelayQueue[T]) Dequeue(ctx context.Context) (T, bool) {
|
||||
// 出队锁:避免因重复获取队列头部同一元素降低性能
|
||||
select {
|
||||
@@ -162,6 +155,16 @@ func (s *DelayQueue[T]) enqueue(val T) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (s *DelayQueue[T]) TryEnqueue(val T) bool {
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
|
||||
if s.priorityQueue.IsFull() {
|
||||
return false
|
||||
}
|
||||
return s.enqueue(val)
|
||||
}
|
||||
|
||||
func (s *DelayQueue[T]) Enqueue(ctx context.Context, val T) bool {
|
||||
for {
|
||||
// 全局锁:避免入队和出队信号的重置与激活出现并发问题
|
||||
|
||||
Reference in New Issue
Block a user