Поправил логику
This commit is contained in:
parent
b695b2c73f
commit
9ab6c82a4a
11
thread.go
11
thread.go
@ -16,12 +16,8 @@ type Manager struct {
|
||||
func (m *Manager) Start(f func()) {
|
||||
m.stopped = make(chan bool, 1)
|
||||
for {
|
||||
if m.runningCount.Load() >= m.Count {
|
||||
continue
|
||||
}
|
||||
|
||||
if m.stop {
|
||||
if m.runningCount.Load() <= 1 {
|
||||
if m.runningCount.Load() < 1 {
|
||||
gol.Debug("thread manager stopped")
|
||||
m.stopped <- true
|
||||
break
|
||||
@ -30,7 +26,12 @@ func (m *Manager) Start(f func()) {
|
||||
continue
|
||||
}
|
||||
|
||||
if m.runningCount.Load() >= m.Count {
|
||||
continue
|
||||
}
|
||||
|
||||
if m.runningCount.Add(1) > m.Count {
|
||||
m.runningCount.Add(-1)
|
||||
gol.Debug("thread manager atomic skip")
|
||||
continue
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user