mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	preen
This commit is contained in:
		| @@ -24,6 +24,13 @@ class GPIOBinarySensorStore { | |||||||
|   bool has_changed() { |   bool has_changed() { | ||||||
|     // No lock needed: single writer (ISR) / single reader (main loop) pattern |     // No lock needed: single writer (ISR) / single reader (main loop) pattern | ||||||
|     // Volatile bool operations are atomic on all ESPHome-supported platforms |     // Volatile bool operations are atomic on all ESPHome-supported platforms | ||||||
|  |     // | ||||||
|  |     // Note: There's a benign race where ISR could set changed_ = true between | ||||||
|  |     // our read and clear. This is intentional and causes no issues because: | ||||||
|  |     // 1. We'll process the state change on the next loop iteration | ||||||
|  |     // 2. Multiple rapid changes between loop iterations would only result in | ||||||
|  |     //    one update anyway (we only care about the final state) | ||||||
|  |     // 3. This avoids the overhead of atomic operations in the ISR | ||||||
|     if (!this->changed_) { |     if (!this->changed_) { | ||||||
|       return false; |       return false; | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user