init: v1.0.0

This commit is contained in:
yaole
2026-05-27 23:03:00 +08:00
commit 8d97f750eb
466 changed files with 80067 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
package internal
import (
"runtime"
"sync/atomic"
)
type SpinLock struct {
v int32
}
func (l *SpinLock) Unlock() {
l.v = 0
}
func (l *SpinLock) Lock() {
for {
if l.v == 0 && atomic.CompareAndSwapInt32(&l.v, 0, 1) {
return
}
// Nginx中考虑了多核的情况,Go中不考虑,因为可能是协程的切换。
runtime.Gosched()
}
}