Skip to content

Commit

Permalink
#### Version 0.9.11
Browse files Browse the repository at this point in the history
* bugfix: add 'StopTask' logic to RemoveTask to fix exceptions where the task cannot be GC after removal
* Thanks to @aixinaxc for #12
* 2023-04-16 13:00 at ShangHai
  • Loading branch information
devfeel committed Apr 16, 2023
1 parent 6e00b3d commit 00116fa
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion constant.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package task

const (
packageVersion = "0.9.10"
packageVersion = "0.9.11"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion example/normal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ func main() {
}
}

time.Sleep(time.Second * 20)
time.Sleep(time.Second * 10)

service.RemoveTask("testloop")
fmt.Println(service.PrintAllTaskCounterInfo())
fmt.Println(service.GetAllTaskCountInfo())

Expand Down
11 changes: 10 additions & 1 deletion tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,15 @@ func (service *TaskService) AddTask(t Task) {

// RemoveTask remove task by taskid
func (service *TaskService) RemoveTask(taskID string) {
//1.stop task running
t, isExists := service.GetTask(taskID)
if !isExists {
return
}
t.Stop()
service.Logger().Info(fmt.Sprint("Task:RemoveTask::StopTask => ", taskID))

//2.delete task from taskMap
service.taskMutex.Lock()
delete(service.taskMap, taskID)
service.taskMutex.Unlock()
Expand Down Expand Up @@ -338,8 +347,8 @@ func (service *TaskService) RemoveAllTask() {
func (service *TaskService) StopAllTask() {
service.Logger().Info("Task:StopAllTask begin...")
for _, v := range service.taskMap {
service.Logger().Info(fmt.Sprint("Task:StopAllTask::StopTask => ", v.TaskID()))
v.Stop()
service.Logger().Info(fmt.Sprint("Task:StopAllTask::StopTask => ", v.TaskID()))
}
service.Logger().Info("Task:StopAllTask end[" + string(len(service.taskMap)) + "]")
}
Expand Down
5 changes: 5 additions & 0 deletions version.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## devfeel/dottask

#### Version 0.9.11
* bugfix: add 'StopTask' logic to RemoveTask to fix exceptions where the task cannot be GC after removal
* Thanks to @aixinaxc for #12
* 2023-04-16 13:00 at ShangHai

#### Version 0.9.10
* feature: add LICENSE file for issue #10, thanks to @katsusan.
* feature: add PackageVersion use to return packageVersion info
Expand Down

0 comments on commit 00116fa

Please sign in to comment.