mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 02:42:25 -05:00 
			
		
		
		
	update dependencies (#296)
This commit is contained in:
		
					parent
					
						
							
								2aaec82732
							
						
					
				
			
			
				commit
				
					
						829a934d23
					
				
			
		
					 124 changed files with 2453 additions and 1588 deletions
				
			
		
							
								
								
									
										45
									
								
								vendor/codeberg.org/gruf/go-errors/once.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								vendor/codeberg.org/gruf/go-errors/once.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,45 @@ | |||
| package errors | ||||
| 
 | ||||
| import ( | ||||
| 	"sync/atomic" | ||||
| 	"unsafe" | ||||
| ) | ||||
| 
 | ||||
| // OnceError is an error structure that supports safe multi-threaded | ||||
| // usage and setting only once (until reset) | ||||
| type OnceError struct { | ||||
| 	err unsafe.Pointer | ||||
| } | ||||
| 
 | ||||
| // NewOnce returns a new OnceError instance | ||||
| func NewOnce() OnceError { | ||||
| 	return OnceError{ | ||||
| 		err: nil, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (e *OnceError) Store(err error) { | ||||
| 	// Nothing to do | ||||
| 	if err == nil { | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	// Only set if not already | ||||
| 	atomic.CompareAndSwapPointer( | ||||
| 		&e.err, | ||||
| 		nil, | ||||
| 		unsafe.Pointer(&err), | ||||
| 	) | ||||
| } | ||||
| 
 | ||||
| func (e *OnceError) Load() error { | ||||
| 	return *(*error)(atomic.LoadPointer(&e.err)) | ||||
| } | ||||
| 
 | ||||
| func (e *OnceError) IsSet() bool { | ||||
| 	return (atomic.LoadPointer(&e.err) != nil) | ||||
| } | ||||
| 
 | ||||
| func (e *OnceError) Reset() { | ||||
| 	atomic.StorePointer(&e.err, nil) | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue