mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
This commit is contained in:
parent
df9122b664
commit
4d7f46a433
1 changed files with 2 additions and 19 deletions
|
|
@ -32,11 +32,6 @@ var (
|
||||||
queueLock = sync.Mutex{}
|
queueLock = sync.Mutex{}
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
QueueStatusRunning = iota
|
|
||||||
QueueStatusClosing
|
|
||||||
)
|
|
||||||
|
|
||||||
type Task struct {
|
type Task struct {
|
||||||
Action string
|
Action string
|
||||||
Handler reflect.Value
|
Handler reflect.Value
|
||||||
|
|
@ -48,7 +43,7 @@ func PrependTask(action string, handler interface{}, args ...interface{}) {
|
||||||
queueLock.Lock()
|
queueLock.Lock()
|
||||||
defer queueLock.Unlock()
|
defer queueLock.Unlock()
|
||||||
|
|
||||||
if QueueStatusRunning != taskQueueStatus {
|
if util.IsExiting {
|
||||||
//logging.LogWarnf("task queue is paused, action [%s] will be ignored", action)
|
//logging.LogWarnf("task queue is paused, action [%s] will be ignored", action)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -61,7 +56,7 @@ func AppendTask(action string, handler interface{}, args ...interface{}) {
|
||||||
queueLock.Lock()
|
queueLock.Lock()
|
||||||
defer queueLock.Unlock()
|
defer queueLock.Unlock()
|
||||||
|
|
||||||
if QueueStatusRunning != taskQueueStatus {
|
if util.IsExiting {
|
||||||
//logging.LogWarnf("task queue is paused, action [%s] will be ignored", action)
|
//logging.LogWarnf("task queue is paused, action [%s] will be ignored", action)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -150,11 +145,6 @@ func StatusJob() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExecTaskJob() {
|
func ExecTaskJob() {
|
||||||
if QueueStatusClosing == taskQueueStatus {
|
|
||||||
clearQueue()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
task := popTask()
|
task := popTask()
|
||||||
if nil == task {
|
if nil == task {
|
||||||
return
|
return
|
||||||
|
|
@ -167,13 +157,6 @@ func ExecTaskJob() {
|
||||||
execTask(task)
|
execTask(task)
|
||||||
}
|
}
|
||||||
|
|
||||||
func clearQueue() {
|
|
||||||
queueLock.Lock()
|
|
||||||
defer queueLock.Unlock()
|
|
||||||
|
|
||||||
taskQueue = []*Task{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func popTask() (ret *Task) {
|
func popTask() (ret *Task) {
|
||||||
queueLock.Lock()
|
queueLock.Lock()
|
||||||
defer queueLock.Unlock()
|
defer queueLock.Unlock()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue