mirror of
				https://github.com/TeaOSLab/EdgeCommon.git
				synced 2025-11-04 13:10:24 +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()
							 | 
						||
| 
								 | 
							
								}
							 |