mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 07:42:26 -05:00 
			
		
		
		
	[feature] Use Read/Write lock for config (#1969)
This commit is contained in:
		
					parent
					
						
							
								6de5ca46f8
							
						
					
				
			
			
				commit
				
					
						f0dad439f6
					
				
			
		
					 3 changed files with 323 additions and 323 deletions
				
			
		|  | @ -105,9 +105,9 @@ func generateFields(output io.Writer, prefixes []string, t reflect.Type) { | |||
| 		// ConfigState structure helper methods | ||||
| 		fmt.Fprintf(output, "// Get%s safely fetches the Configuration value for state's '%s' field\n", name, fieldPath) | ||||
| 		fmt.Fprintf(output, "func (st *ConfigState) Get%s() (v %s) {\n", name, fieldType) | ||||
| 		fmt.Fprintf(output, "\tst.mutex.Lock()\n") | ||||
| 		fmt.Fprintf(output, "\tst.mutex.RLock()\n") | ||||
| 		fmt.Fprintf(output, "\tv = st.config.%s\n", fieldPath) | ||||
| 		fmt.Fprintf(output, "\tst.mutex.Unlock()\n") | ||||
| 		fmt.Fprintf(output, "\tst.mutex.RUnlock()\n") | ||||
| 		fmt.Fprintf(output, "\treturn\n") | ||||
| 		fmt.Fprintf(output, "}\n\n") | ||||
| 		fmt.Fprintf(output, "// Set%s safely sets the Configuration value for state's '%s' field\n", name, fieldPath) | ||||
|  |  | |||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							|  | @ -32,7 +32,7 @@ import ( | |||
| type ConfigState struct { //nolint | ||||
| 	viper  *viper.Viper | ||||
| 	config Configuration | ||||
| 	mutex  sync.Mutex | ||||
| 	mutex  sync.RWMutex | ||||
| } | ||||
| 
 | ||||
| // NewState returns a new initialized ConfigState instance. | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue