Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
gostnops
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wei.xuan
gostnops
Commits
3ac9f982
Commit
3ac9f982
authored
Dec 01, 2020
by
AlexStocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mod: add remark for simple task pool
parent
522be9af
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
task_pool.go
sync/task_pool.go
+6
-2
No files found.
sync/task_pool.go
View file @
3ac9f982
...
...
@@ -226,8 +226,8 @@ func (p *TaskPool) Close() {
// Task Pool Simple
/////////////////////////////////////////
type
taskPoolSimple
struct
{
work
chan
task
sem
chan
struct
{}
work
chan
task
// task channel
sem
chan
struct
{}
// gr pool size
wg
sync
.
WaitGroup
...
...
@@ -274,15 +274,19 @@ func (p *taskPoolSimple) AddTaskAlways(t task) {
select
{
case
p
.
work
<-
t
:
// exec @t in gr pool
return
default
:
}
select
{
case
p
.
work
<-
t
:
// exec @t in gr pool
case
p
.
sem
<-
struct
{}{}
:
// add a gr to the gr pool
p
.
wg
.
Add
(
1
)
go
p
.
worker
(
t
)
default
:
// gen a gr temporarily
goSafely
(
t
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment