代码拉取完成,页面将自动刷新
package antnet
import (
"sync/atomic"
)
func Go(fn func()) {
pc := Config.PoolSize + 1
select {
case poolChan <- fn:
return
default:
pc = atomic.AddInt32(&poolGoCount, 1)
if pc > Config.PoolSize {
atomic.AddInt32(&poolGoCount, -1)
}
}
waitAll.Add(1)
var debugStr string
id := atomic.AddUint32(&goid, 1)
c := atomic.AddInt32(&gocount, 1)
if DefLog.Level() <= LogLevelDebug {
debugStr = LogSimpleStack()
LogDebug("goroutine start id:%d count:%d from:%s", id, c, debugStr)
}
go func() {
Try(fn, nil)
for pc <= Config.PoolSize {
select {
case <-stopChanForGo:
pc = Config.PoolSize + 1
case nfn := <-poolChan:
Try(nfn, nil)
}
}
waitAll.Done()
c = atomic.AddInt32(&gocount, -1)
if DefLog.Level() <= LogLevelDebug {
LogDebug("goroutine end id:%d count:%d from:%s", id, c, debugStr)
}
}()
}
func Go2(fn func(cstop chan struct{})) {
Go(func() {
fn(stopChanForGo)
})
}
func GoArgs(fn func(...interface{}), args ...interface{}) {
Go(func() {
fn(args...)
})
}
func goForRedis(fn func()) {
waitAllForRedis.Add(1)
var debugStr string
id := atomic.AddUint32(&goid, 1)
c := atomic.AddInt32(&gocount, 1)
if DefLog.Level() <= LogLevelDebug {
debugStr = LogSimpleStack()
LogDebug("goroutine start id:%d count:%d from:%s", id, c, debugStr)
}
go func() {
Try(fn, nil)
waitAllForRedis.Done()
c = atomic.AddInt32(&gocount, -1)
if DefLog.Level() <= LogLevelDebug {
LogDebug("goroutine end id:%d count:%d from:%s", id, c, debugStr)
}
}()
}
func goForLog(fn func(cstop chan struct{})) bool {
if IsStop() {
return false
}
waitAllForLog.Add(1)
go func() {
fn(stopChanForLog)
waitAllForLog.Done()
}()
return true
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。