增加读写线程限制相关测试用例

This commit is contained in:
刘祥超
2024-04-29 23:10:02 +08:00
parent fa02713ab5
commit aa2467c7cf
2 changed files with 64 additions and 1 deletions

View File

@@ -3,6 +3,7 @@
package fsutils
import (
"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
"runtime"
"time"
)
@@ -68,5 +69,13 @@ func (this *Limiter) TryAck() bool {
}
func (this *Limiter) Release() {
this.threads <- struct{}{}
select {
case this.threads <- struct{}{}:
default:
remotelogs.Error("FS_LIMITER", "Limiter Ack()/Release() should appeared as a pair")
}
}
func (this *Limiter) FreeThreads() int {
return len(this.threads)
}