mirror of
				https://github.com/immich-app/immich.git
				synced 2025-10-31 02:27:08 -04:00 
			
		
		
		
	* feat(mobile): drift map page * refactor: map query * perf: do not filter markers * fix: refresh timeline by key * chore: rename * remove ref listen and global key * clean code * remove locked and favorite * temporary change for stress test * optimizations * fix bottom sheet * cleaner bounds check * cleanup * feat: back button --------- Co-authored-by: wuzihao051119 <wuzihao051119@outlook.com> Co-authored-by: Alex <alex.tran1502@gmail.com>
		
			
				
	
	
		
			22 lines
		
	
	
		
			628 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			628 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'dart:async';
 | |
| 
 | |
| /// Async mutex to guarantee actions are performed sequentially and do not interleave
 | |
| class AsyncMutex {
 | |
|   Future _running = Future.value(null);
 | |
|   int _enqueued = 0;
 | |
| 
 | |
|   int get enqueued => _enqueued;
 | |
| 
 | |
|   /// Execute [operation] exclusively, after any currently running operations.
 | |
|   /// Returns a [Future] with the result of the [operation].
 | |
|   Future<T> run<T>(Future<T> Function() operation) {
 | |
|     final completer = Completer<T>();
 | |
|     _enqueued++;
 | |
|     _running.whenComplete(() {
 | |
|       _enqueued--;
 | |
|       completer.complete(Future<T>.sync(operation));
 | |
|     });
 | |
|     return _running = completer.future;
 | |
|   }
 | |
| }
 |