Files
EdgeNode/internal/utils/bfs/thread_limiters.go
2024-04-27 07:09:14 +08:00

26 lines
578 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
package bfs
import "github.com/TeaOSLab/EdgeNode/internal/zero"
// TODO 使用atomic代替channel需要使用基准测试对比性能
var readThreadsLimiter = make(chan zero.Zero, 16)
var writeThreadsLimiter = make(chan zero.Zero, 16)
func AckReadThread() {
readThreadsLimiter <- zero.Zero{}
}
func ReleaseReadThread() {
<-readThreadsLimiter
}
func AckWriteThread() {
writeThreadsLimiter <- zero.Zero{}
}
func ReleaseWriteThread() {
<-writeThreadsLimiter
}