<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	<meta charset="utf-8"/>
	<meta name="viewport" content="width=device-width initial-scale=1"/>
	<title>LispKit Thread Future</title>
	
	
	
	
	<link rel="stylesheet" href="../css/main.css"/>
	
	<script src="../css/nav.js"></script>
	
</head>

	<body class="help-page">
		<header class="banner">
	<nav id="menu" class="dynamic">
		
		
		<ul>
		
			
				
				<li>
					<a href="../en.lproj/-welcome.html"><nav>Overview</nav></a>
				</li>
				
			
		
			
				
				<li>
					<a href="../en.lproj/0-sessions.html"><nav>Sessions</nav></a>
				</li>
				
			
		
			
				
			
		
			
				
				<li>
					<a href="../en.lproj/1-editing-code.html"><nav>Editing code</nav></a>
				</li>
				
			
		
			
				
				<li>
					<a href="../en.lproj/2-customizing-prefs.html"><nav>Customizing preferences</nav></a>
				</li>
				
			
		
			
				
				<li>
					<a href="../en.lproj/3-menu-overview.html"><nav>Menu overview</nav></a>
				</li>
				
			
		
			
				
				<li>
					<a href="../en.lproj/4-getting-started.html"><nav>Getting started with Scheme</nav></a>
				</li>
				
			
		
			
				
				<li class="group">
					<a name="name"><nav> Language </nav></a>
					<ul name="list">
					
						<li>
							<a href="../en.lproj/5-1-features.html"><nav>Language features</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/5-2-limitations.html"><nav>Language limitations</nav></a>
						</li>
					
					</ul>
				</li>
			
		
			
				
				<li>
					<a href="../en.lproj/6-libraries.html"><nav>Library overview</nav></a>
				</li>
				
			
		
			
				
				<li class="group">
					<a name="name"><nav> Libraries </nav></a>
					<ul name="list">
					
						<li>
							<a href="../en.lproj/7-0-lisppad-applescript.html"><nav>LispPad AppleScript</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-0-lisppad-draw-map.html"><nav>LispPad Draw Map</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-0-lisppad-location.html"><nav>LispPad Location</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-0-lisppad-speech.html"><nav>LispPad Speech</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-0-lisppad-system.html"><nav>LispPad System macOS</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-0-lisppad-turtle.html"><nav>LispPad Turtle</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-archive-tar.html"><nav>LispKit Archive Tar</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-archive-zip.html"><nav>LispKit Archive Zip</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-base.html"><nav>LispKit Base</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-bitset.html"><nav>LispKit Bitset</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-box.html"><nav>LispKit Box</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-bytevector.html"><nav>LispKit Bytevector</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-char.html"><nav>LispKit Char</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-char-set.html"><nav>LispKit Char-Set</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-combinator.html"><nav>LispKit Combinator</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-comparator.html"><nav>LispKit Comparator</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-control.html"><nav>LispKit Control</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-core.html"><nav>LispKit Core</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-crypto.html"><nav>LispKit Crypto</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-csv.html"><nav>LispKit CSV</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-datatype.html"><nav>LispKit Datatype</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-date-time.html"><nav>LispKit Date-Time</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-debug.html"><nav>LispKit Debug</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-disjoint-set.html"><nav>LispKit Disjoint-Set</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-draw.html"><nav>LispKit Draw</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-draw-barcode.html"><nav>LispKit Draw Barcode</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-draw-chart-bar.html"><nav>LispKit Draw Chart Bar</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-draw-map.html"><nav>LispKit Draw Map</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-draw-turtle.html"><nav>LispKit Draw Turtle</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-draw-web.html"><nav>LispKit Draw Web</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-dynamic.html"><nav>LispKit Dynamic</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-enum.html"><nav>LispKit Enum</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-format.html"><nav>LispKit Format</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-graph.html"><nav>LispKit Graph</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-gvector.html"><nav>LispKit GVector</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-hashtable.html"><nav>LispKit Hashtable</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-heap.html"><nav>LispKit Heap</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-http.html"><nav>LispKit HTTP</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-http-oauth.html"><nav>LispKit HTTP OAuth</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-http-server.html"><nav>LispKit HTTP Server</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-image.html"><nav>LispKit Image</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-image-process.html"><nav>LispKit Image Process</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-iterate.html"><nav>LispKit Iterate</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-json.html"><nav>LispKit JSON</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-json-schema.html"><nav>LispKit JSON Schema</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-list.html"><nav>LispKit List</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-list-set.html"><nav>LispKit List Set</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-location.html"><nav>LispKit Location</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-log.html"><nav>LispKit Log</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-markdown.html"><nav>LispKit Markdown</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-match.html"><nav>LispKit Match</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-math.html"><nav>LispKit Math</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-math-matrix.html"><nav>LispKit Math Matrix</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-math-stats.html"><nav>LispKit Math Stats</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-math-util.html"><nav>LispKit Math Util</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-object.html"><nav>LispKit Object</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-pdf.html"><nav>LispKit PDF</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-port.html"><nav>LispKit Port</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-prolog.html"><nav>LispKit Prolog</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-queue.html"><nav>LispKit Queue</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-record.html"><nav>LispKit Record</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-regexp.html"><nav>LispKit Regexp</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-serialize.html"><nav>LispKit Serialize</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-set.html"><nav>LispKit Set</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-sqlite.html"><nav>LispKit SQLite</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-stack.html"><nav>LispKit Stack</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-stream.html"><nav>LispKit Stream</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-string.html"><nav>LispKit String</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-styled-text.html"><nav>LispKit Styled-Text</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-system.html"><nav>LispKit System</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-system-keychain.html"><nav>LispKit System Keychain</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-system-os.html"><nav>LispKit System Call</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-system-pasteboard.html"><nav>LispKit System Pasteboard</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-test.html"><nav>LispKit Test</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-text-table.html"><nav>LispKit Text-Table</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-thread.html"><nav>LispKit Thread</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-thread-channel.html"><nav>LispKit Thread Channel</nav></a>
						</li>
					
						<li class="active">
							<a href="../en.lproj/7-5-lispkit-thread-future"><nav>LispKit Thread Future</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-thread-shared-queue.html"><nav>LispKit Thread Shared-Queue</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-type.html"><nav>LispKit Type</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-url.html"><nav>LispKit URL</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-vector.html"><nav>LispKit Vector</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/7-5-lispkit-vision.html"><nav>LispKit Vision</nav></a>
						</li>
					
					</ul>
				</li>
			
		
			
				
				<li class="group">
					<a name="name"><nav> Examples </nav></a>
					<ul name="list">
					
						<li>
							<a href="../en.lproj/8-1-example.html"><nav>Math functions</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/8-2-example.html"><nav>AVL trees</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/8-3-example.html"><nav>Prolog</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/8-4-example.html"><nav>Topological sort</nav></a>
						</li>
					
						<li>
							<a href="../en.lproj/8-5-example.html"><nav>Drawing and scripting</nav></a>
						</li>
					
					</ul>
				</li>
			
		
			
				
				<li>
					<a href="../en.lproj/9-release-notes.html"><nav>Release Notes</nav></a>
				</li>
				
			
		
		</ul>
	</nav>
</header>

		<main>
			<h1><a name="lp-lispkit-thread-future"></a>LispKit Thread Future</h1>

Library `(lispkit thread future)` implements _futures_, an abstraction allowing for fine-grained concurrent computation of values. A _future_ encapsulates an expression whose computation may occur in parallel with the code of the calling thread and all other threads that are currently executed including other futures. Like _promises_, _futures_ are proxies that can be queried to obtain the value of the encapsulated computation. While _promises_ compute values on demand, _futures_ compute values in parallel.

Futures are created either with special form `future` or procedure `make-future`. The creation of a future implicitly kicks off the parallel computation of the future's value. The value can be accessed via `future-get`, which will block if the computation of the value has not finished yet. `future-get` can optionally be given a timeout to control the maximum number of seconds a thread is waiting for the results of a future to become available. Via procedure `future-done?` it is possible to check in a non-blocking manner if the future has finished computing its value already.

**future-type-tag** <span style="float:right;text-align:rigth;">[constant]</span>  

Symbol representing the `future` type. The `type-for` procedure of library `(lispkit type)` returns this symbol for all future objects.

**(future? _obj_)** &nbsp;&nbsp;&nbsp; <span style="float:right;text-align:rigth;">[procedure]</span>  

Returns `#t` if _obj_ is a future object; `#f` otherwise.

**(future _expr_)** <span style="float:right;text-align:rigth;">[syntax]</span>   

Via the `future` syntax it is possible to create a future which evaluates _expr_ in parallel in the same environment in which `future` appears. The `future` syntax returns a future object which eventually will contain the result of evaluating _expr_ concurrently. If an exception is raised within _expr_, it is not caught but delivered later when `future-get` gets invoked.

**(make-future _proc_)** &nbsp;&nbsp;&nbsp; <span style="float:right;text-align:rigth;">[procedure]</span>  

Returns a new future which computes its value by executing thunk _proc_ in parallel in the same environment in which `make-future` is called. If an exception is raised within _expr_, it is not caught but delivered later when `future-get` gets invoked.

**(make-evaluated-future _obj_)** &nbsp;&nbsp;&nbsp; <span style="float:right;text-align:rigth;">[procedure]</span>  

Returns a new future which encapsulates _obj_ as its value without doing any computation. When `future-get` gets invoked, _obj_ is returned.

**(make-failing-future _exc_)** &nbsp;&nbsp;&nbsp; <span style="float:right;text-align:rigth;">[procedure]</span>  

Returns a new future which encapsulates exception _exc_ as its value without doing any computation. When `future-get` gets invoked, _exc_ is being raised.

**(future-done? _f_)** &nbsp;&nbsp;&nbsp; <span style="float:right;text-align:rigth;">[procedure]</span>  

Returns `#t` if the computation of future _f_ is finished and the value of _f_ available; otherwise `#f` is returned. This procedure does not block.

**(future-get _f_)** &nbsp;&nbsp;&nbsp; <span style="float:right;text-align:rigth;">[procedure]</span>   
**(future-get _f timeout_)**  
**(future-get _f timeout default_)**  

Returns the value associated with future _f_. If the value of _f_ is not available yet (because the computation is still ongoing), this procedure will block. _timeout_ defines the maximum number of seconds `future-get` is waiting for receiving the value of _f_. If _timeout_ is not provided, `future-get` will wait indefinitely. When `future-get` times out, _default_ is returned as its result. If _default_ is not provided, then `future-get` will raise an error when timing out. If an exception is raised during the computation, `future-get` will raise this exception every single time it is invoked.

**(touch _f_)** &nbsp;&nbsp;&nbsp; <span style="float:right;text-align:rigth;">[procedure]</span>  

`(touch f)` is equivalent to `(future-get f)`, but does not support the optional parameters of `future-get`. It is provided for compatibility with _future_ implementations of other Scheme implementations.


		</main>
		<footer>
Copyright 2017-2025 Matthias Zenger. All rights reserved.
</footer>

	</body>
</html>
