18 lines
		
	
	
		
			535 B
		
	
	
	
		
			Factor
		
	
	
			
		
		
	
	
			18 lines
		
	
	
		
			535 B
		
	
	
	
		
			Factor
		
	
	
| ! Copyright (C) 2005, 2008 Chris Double, Slava Pestov.
 | |
| ! See http://factorcode.org/license.txt for BSD license.
 | |
| USING: concurrency.promises concurrency.mailboxes kernel arrays
 | |
| continuations accessors ;
 | |
| IN: concurrency.futures
 | |
| 
 | |
| : future ( quot -- future )
 | |
|     <promise> [
 | |
|         [ [ >r call r> fulfill ] 2curry "Future" ] keep
 | |
|         mailbox>> spawn-linked-to drop
 | |
|     ] keep ; inline
 | |
| 
 | |
| : ?future-timeout ( future timeout -- value )
 | |
|     ?promise-timeout ?linked ;
 | |
| 
 | |
| : ?future ( future -- value )
 | |
|     ?promise ?linked ;
 |