github.com/TeaOSLab/EdgeNode@v1.3.8/internal/utils/bfs/threads_limiter.go (about)

     1  // Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
     2  
     3  package bfs
     4  
     5  import "github.com/TeaOSLab/EdgeNode/internal/zero"
     6  
     7  // TODO 线程数可以根据硬盘数量动态调整?
     8  var readThreadsLimiter = make(chan zero.Zero, 8)
     9  var writeThreadsLimiter = make(chan zero.Zero, 8)
    10  
    11  func AckReadThread() {
    12  	readThreadsLimiter <- zero.Zero{}
    13  }
    14  
    15  func ReleaseReadThread() {
    16  	<-readThreadsLimiter
    17  }
    18  
    19  func AckWriteThread() {
    20  	writeThreadsLimiter <- zero.Zero{}
    21  }
    22  
    23  func ReleaseWriteThread() {
    24  	<-writeThreadsLimiter
    25  }