mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			14 lines
		
	
	
		
			375 B
		
	
	
	
		
			Hy
		
	
	
	
	
	
			
		
		
	
	
			14 lines
		
	
	
		
			375 B
		
	
	
	
		
			Hy
		
	
	
	
	
	
| ;; The concurrent.futures example in Hy.
 | |
| 
 | |
| (import [concurrent.futures [ThreadPoolExecutor as-completed]]
 | |
|         [random [randint]]
 | |
|         [sh [sleep]])
 | |
| 
 | |
| (defn task-to-do []
 | |
|   (sleep (randint 1 5)))
 | |
| 
 | |
| (with-as (ThreadPoolExecutor 10) executor
 | |
|   (setv jobs (list-comp (.submit executor task-to-do) (x (range 0 10))))
 | |
|   (for (future (as-completed jobs))
 | |
|     (.result future)))
 |