mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-03 23:20:25 +08:00
22 lines
265 B
Go
22 lines
265 B
Go
|
|
package shared
|
||
|
|
|
||
|
|
import (
|
||
|
|
"sync"
|
||
|
|
)
|
||
|
|
|
||
|
|
var Locker = new(FileLocker)
|
||
|
|
|
||
|
|
// global file modify locker
|
||
|
|
type FileLocker struct {
|
||
|
|
locker sync.Mutex
|
||
|
|
}
|
||
|
|
|
||
|
|
// lock
|
||
|
|
func (this *FileLocker) Lock() {
|
||
|
|
this.locker.Lock()
|
||
|
|
}
|
||
|
|
|
||
|
|
func (this *FileLocker) Unlock() {
|
||
|
|
this.locker.Unlock()
|
||
|
|
}
|