mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-05 23:05:45 +00:00
chore(runtime): fetch build data
Signed-off-by: Bo-Yi.Wu <[email protected]>
This commit is contained in:
1 parent
631f801aa6
commit
d3d56ed0ef
9 files changed
+77
-78
No files matched your search
@@ -1,31 +1,11 @@
|
||||
package runtime
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var globalTaskMap sync.Map
|
||||
|
||||
// startTask adds the task to global map
|
||||
func startTask(buildID int64, ctx context.Context) error {
|
||||
_, exist := globalTaskMap.Load(buildID)
|
||||
if exist {
|
||||
return fmt.Errorf("task %d already exists", buildID)
|
||||
}
|
||||
|
||||
task := NewTask(buildID)
|
||||
|
||||
// set task ve to global map
|
||||
// when task is done or canceled, it will be removed from the map
|
||||
globalTaskMap.Store(buildID, task)
|
||||
|
||||
go task.Run(ctx)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// finishTask removes the task from global map
|
||||
func finishTask(buildID int64) {
|
||||
globalTaskMap.Delete(buildID)
|
||||
|
||||
Reference in new issue
Block a user