<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
future	O
,	O
promise	O
,	O
delay	O
,	O
and	O
deferred	O
refer	O
to	O
constructs	O
used	O
for	O
synchronizing	O
program	O
execution	B-General_Concept
in	O
some	O
concurrent	B-Operating_System
programming	O
languages	O
.	O
</s>
<s>
Futures	B-Operating_System
and	I-Operating_System
promises	I-Operating_System
originated	O
in	O
functional	B-Language
programming	I-Language
and	O
related	O
paradigms	O
(	O
such	O
as	O
logic	B-Language
programming	I-Language
)	O
to	O
decouple	O
a	O
value	O
(	O
a	O
future	O
)	O
from	O
how	O
it	O
was	O
computed	O
(	O
a	O
promise	O
)	O
,	O
allowing	O
the	O
computation	O
to	O
be	O
done	O
more	O
flexibly	O
,	O
notably	O
by	O
parallelizing	O
it	O
.	O
</s>
<s>
Later	O
,	O
it	O
found	O
use	O
in	O
distributed	B-Architecture
computing	I-Architecture
,	O
in	O
reducing	O
the	O
latency	O
from	O
communication	O
round	O
trips	O
.	O
</s>
<s>
Later	O
still	O
,	O
it	O
gained	O
more	O
use	O
by	O
allowing	O
writing	O
asynchronous	O
programs	O
in	O
direct	B-Application
style	I-Application
,	O
rather	O
than	O
in	O
continuation-passing	B-Application
style	I-Application
.	O
</s>
<s>
Use	O
of	O
futures	O
may	O
be	O
implicit	O
(	O
any	O
use	O
of	O
the	O
future	O
automatically	O
obtains	O
its	O
value	O
,	O
as	O
if	O
it	O
were	O
an	O
ordinary	O
reference	O
)	O
or	O
explicit	O
(	O
the	O
user	O
must	O
call	O
a	O
function	O
to	O
obtain	O
the	O
value	O
,	O
such	O
as	O
the	O
get	O
method	O
of	O
in	O
Java	B-Language
)	O
.	O
</s>
<s>
The	O
original	O
Baker	O
and	O
Hewitt	O
paper	O
described	O
implicit	O
futures	O
,	O
which	O
are	O
naturally	O
supported	O
in	O
the	O
actor	B-Application
model	I-Application
of	O
computation	O
and	O
pure	O
object-oriented	B-Language
programming	I-Language
languages	I-Language
like	O
Smalltalk	B-Application
.	O
</s>
<s>
The	O
use	O
of	O
futures	O
can	O
dramatically	O
reduce	O
latency	O
in	O
distributed	B-Architecture
systems	I-Architecture
.	O
</s>
<s>
For	O
instance	O
,	O
futures	O
enable	O
promise	O
pipelining	O
,	O
as	O
implemented	O
in	O
the	O
languages	O
E	B-Language
and	O
Joule	B-Language
,	O
which	O
was	O
also	O
called	O
call-stream	B-Operating_System
in	O
the	O
language	O
Argus	B-Language
.	O
</s>
<s>
Consider	O
an	O
expression	O
involving	O
conventional	O
remote	B-Operating_System
procedure	I-Operating_System
calls	I-Operating_System
,	O
such	O
as	O
:	O
</s>
<s>
The	O
syntax	O
used	O
here	O
is	O
that	O
of	O
the	O
language	O
E	B-Language
,	O
where	O
x	O
<	O
-	O
a( )	O
means	O
to	O
send	O
the	O
message	O
a( )	O
asynchronously	O
to	O
x	O
.	O
</s>
<s>
All	O
three	O
variables	O
are	O
immediately	O
assigned	O
futures	O
for	O
their	O
results	O
,	O
and	O
execution	B-General_Concept
proceeds	O
to	O
subsequent	O
statements	O
.	O
</s>
<s>
Promise	O
pipelining	O
also	O
should	O
not	O
be	O
confused	O
with	O
pipelined	O
message	O
processing	O
in	O
actor	B-Application
systems	I-Application
,	O
where	O
it	O
is	O
possible	O
for	O
an	O
actor	O
to	O
specify	O
and	O
begin	O
executing	O
a	O
behaviour	O
for	O
the	O
next	O
message	O
before	O
having	O
completed	O
processing	O
of	O
the	O
current	O
message	O
.	O
</s>
<s>
In	O
some	O
programming	O
languages	O
such	O
as	O
Oz	B-Language
,	O
E	B-Language
,	O
and	O
AmbientTalk	B-Language
,	O
it	O
is	O
possible	O
to	O
obtain	O
a	O
read-only	O
view	O
of	O
a	O
future	O
,	O
which	O
allows	O
reading	O
its	O
value	O
when	O
resolved	O
,	O
but	O
does	O
not	O
permit	O
resolving	O
it	O
:	O
</s>
<s>
In	O
Oz	B-Language
,	O
the	O
!	O
</s>
<s>
In	O
E	B-Language
and	O
AmbientTalk	B-Language
,	O
a	O
future	O
is	O
represented	O
by	O
a	O
pair	O
of	O
values	O
called	O
a	O
promise/resolver	O
pair	O
.	O
</s>
<s>
The	O
promise	O
represents	O
the	O
read-only	O
view	O
,	O
and	O
the	O
resolver	B-Operating_System
is	O
needed	O
to	O
set	O
the	O
future	O
's	O
value	O
.	O
</s>
<s>
In	O
C++11	B-Language
a	O
std::future	O
provides	O
a	O
read-only	O
view	O
.	O
</s>
<s>
In	O
the	O
Dojo	B-General_Concept
Toolkit	I-General_Concept
's	O
Deferred	O
API	O
as	O
of	O
version	O
1.5	O
,	O
a	O
consumer-only	O
promise	O
object	O
represents	O
a	O
read-only	O
view	O
.	O
</s>
<s>
In	O
.NET	B-Application
Framework	I-Application
4.0	O
System.Threading.Tasks.Taskxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1	O
represents	O
a	O
read-only	O
view	O
.	O
</s>
<s>
In	O
a	O
system	O
that	O
also	O
supports	O
pipelining	O
,	O
the	O
sender	O
of	O
an	O
asynchronous	O
message	O
(	O
with	O
result	O
)	O
receives	O
the	O
read-only	O
promise	O
for	O
the	O
result	O
,	O
and	O
the	O
target	O
of	O
the	O
message	O
receives	O
the	O
resolver	B-Operating_System
.	O
</s>
<s>
Some	O
languages	O
,	O
such	O
as	O
Alice	B-Language
ML	I-Language
,	O
define	O
futures	O
that	O
are	O
associated	O
with	O
a	O
specific	O
thread	O
that	O
computes	O
the	O
future	O
's	O
value	O
.	O
</s>
<s>
A	O
lazy	O
future	O
is	O
similar	O
to	O
a	O
thunk	B-Application
,	O
in	O
the	O
sense	O
of	O
a	O
delayed	B-Application
computation	I-Application
.	O
</s>
<s>
Alice	B-Language
ML	I-Language
also	O
supports	O
futures	O
that	O
can	O
be	O
resolved	O
by	O
any	O
thread	O
,	O
and	O
calls	O
these	O
promises	O
.	O
</s>
<s>
This	O
use	O
of	O
promise	O
is	O
different	O
from	O
its	O
use	O
in	O
E	B-Language
as	O
described	O
above	O
.	O
</s>
<s>
In	O
Alice	B-Language
,	O
a	O
promise	O
is	O
not	O
a	O
read-only	O
view	O
,	O
and	O
promise	O
pipelining	O
is	O
unsupported	O
.	O
</s>
<s>
If	O
the	O
value	O
of	O
a	O
future	O
is	O
accessed	O
asynchronously	O
,	O
for	O
example	O
by	O
sending	O
a	O
message	O
to	O
it	O
,	O
or	O
by	O
explicitly	O
waiting	O
for	O
it	O
using	O
a	O
construct	O
such	O
as	O
when	O
in	O
E	B-Language
,	O
then	O
there	O
is	O
no	O
difficulty	O
in	O
delaying	O
until	O
the	O
future	O
is	O
resolved	O
before	O
the	O
message	O
can	O
be	O
received	O
or	O
the	O
wait	O
completes	O
.	O
</s>
<s>
This	O
is	O
the	O
semantics	O
of	O
dataflow	B-Operating_System
variables	I-Operating_System
in	O
the	O
language	O
Oz	B-Language
.	O
</s>
<s>
the	O
attempted	O
synchronous	O
access	O
could	O
always	O
signal	O
an	O
error	O
,	O
for	O
example	O
throwing	O
an	O
exception	B-General_Concept
.	O
</s>
<s>
This	O
is	O
the	O
semantics	O
of	O
remote	O
promises	O
in	O
E	B-Language
.	O
</s>
<s>
This	O
would	O
have	O
the	O
disadvantage	O
of	O
introducing	O
nondeterminism	O
and	O
the	O
potential	O
for	O
race	B-Operating_System
conditions	I-Operating_System
,	O
and	O
seems	O
to	O
be	O
an	O
uncommon	O
design	O
choice	O
.	O
</s>
<s>
As	O
an	O
example	O
of	O
the	O
first	O
possibility	O
,	O
in	O
C++11	B-Language
,	O
a	O
thread	O
that	O
needs	O
the	O
value	O
of	O
a	O
future	O
can	O
block	O
until	O
it	O
is	O
available	O
by	O
calling	O
the	O
wait( )	O
or	O
get( )	O
member	O
functions	O
.	O
</s>
<s>
Futures	O
are	O
a	O
particular	O
case	O
of	O
the	O
synchronization	O
primitive	O
"	O
events	B-Operating_System
,	O
"	O
which	O
can	O
be	O
completed	O
only	O
once	O
.	O
</s>
<s>
In	O
general	O
,	O
events	B-Operating_System
can	O
be	O
reset	O
to	O
initial	O
empty	O
state	O
and	O
,	O
thus	O
,	O
completed	O
as	O
many	O
times	O
as	O
you	O
like	O
.	O
</s>
<s>
An	O
I-var	B-Operating_System
(	O
as	O
in	O
the	O
language	O
Id	B-Language
)	O
is	O
a	O
future	O
with	O
blocking	O
semantics	O
as	O
defined	O
above	O
.	O
</s>
<s>
An	O
I-structure	B-Operating_System
is	O
a	O
data	B-General_Concept
structure	I-General_Concept
containing	O
I-vars	B-Operating_System
.	O
</s>
<s>
A	O
concurrent	B-Operating_System
logic	I-Operating_System
variable	I-Operating_System
is	O
similar	O
to	O
a	O
future	O
,	O
but	O
is	O
updated	O
by	O
unification	B-Algorithm
,	O
in	O
the	O
same	O
way	O
as	O
logic	O
variables	O
in	O
logic	B-Language
programming	I-Language
.	O
</s>
<s>
The	O
dataflow	B-Operating_System
variables	I-Operating_System
of	O
Oz	B-Language
act	O
as	O
concurrent	B-Operating_System
logic	I-Operating_System
variables	I-Operating_System
,	O
and	O
also	O
have	O
blocking	O
semantics	O
as	O
mentioned	O
above	O
.	O
</s>
<s>
A	O
concurrent	B-Operating_System
constraint	O
variable	O
is	O
a	O
generalization	O
of	O
concurrent	B-Operating_System
logic	I-Operating_System
variables	I-Operating_System
to	O
support	O
constraint	B-Application
logic	I-Application
programming	I-Application
:	O
the	O
constraint	O
may	O
be	O
narrowed	O
multiple	O
times	O
,	O
indicating	O
smaller	O
sets	O
of	O
possible	O
values	O
.	O
</s>
<s>
Typically	O
there	O
is	O
a	O
way	O
to	O
specify	O
a	O
thunk	B-Application
that	O
should	O
run	O
whenever	O
the	O
constraint	O
is	O
narrowed	O
further	O
;	O
this	O
is	O
needed	O
to	O
support	O
constraint	O
propagation	O
.	O
</s>
<s>
To	O
implement	O
implicit	O
lazy	O
thread-specific	O
futures	O
(	O
as	O
provided	O
by	O
Alice	B-Language
ML	I-Language
,	O
for	O
example	O
)	O
in	O
terms	O
in	O
non-thread-specific	O
futures	O
,	O
needs	O
a	O
mechanism	O
to	O
determine	O
when	O
the	O
future	O
's	O
value	O
is	O
first	O
needed	O
(	O
for	O
example	O
,	O
the	O
WaitNeeded	O
construct	O
in	O
Oz	B-Language
)	O
.	O
</s>
<s>
The	O
evaluation	B-Language
strategy	I-Language
of	O
futures	O
,	O
which	O
may	O
be	O
termed	O
call	O
by	O
future	O
,	O
is	O
non-deterministic	O
:	O
the	O
value	O
of	O
a	O
future	O
will	O
be	O
evaluated	O
at	O
some	O
time	O
between	O
when	O
the	O
future	O
is	O
created	O
and	O
when	O
its	O
value	O
is	O
used	O
,	O
but	O
the	O
precise	O
time	O
is	O
not	O
determined	O
beforehand	O
and	O
can	O
change	O
from	O
run	O
to	O
run	O
.	O
</s>
<s>
Lazy	O
futures	O
are	O
of	O
use	O
in	O
languages	O
which	O
evaluation	B-Language
strategy	I-Language
is	O
by	O
default	O
not	O
lazy	O
.	O
</s>
<s>
For	O
example	O
,	O
in	O
C++11	B-Language
such	O
lazy	O
futures	O
can	O
be	O
created	O
by	O
passing	O
the	O
std::launch::deferred	O
launch	O
policy	O
to	O
std::async	O
,	O
along	O
with	O
the	O
function	O
to	O
compute	O
the	O
value	O
.	O
</s>
<s>
In	O
the	O
actor	B-Application
model	I-Application
,	O
an	O
expression	O
of	O
the	O
form	O
future	O
<Expression> is defined by how it responds to an Eval message with environment E and customer C as follows: The future expression responds to the Eval message by sending the customer C a newly created actor F (the proxy for the response of evaluating <Expression> )  as a return value concurrently with sending <Expression>	O
an	O
Eval	O
message	O
with	O
environment	O
E	B-Language
and	O
customer	O
C	O
.	O
The	O
default	O
behavior	O
of	O
F	O
is	O
as	O
follows	O
:	O
</s>
<s>
When	O
F	O
receives	O
a	O
request	O
R	B-Language
,	O
then	O
it	O
checks	O
to	O
see	O
if	O
it	O
has	O
already	O
received	O
a	O
response	O
(	O
that	O
can	O
either	O
be	O
a	O
return	O
value	O
or	O
a	O
thrown	O
exception	B-General_Concept
)	O
from	O
evaluating	O
<Expression>	O
proceeding	O
as	O
follows	O
:	O
</s>
<s>
If	O
V	O
is	O
a	O
return	O
value	O
,	O
then	O
it	O
is	O
sent	O
the	O
request	O
R	B-Language
.	O
</s>
<s>
If	O
V	O
is	O
an	O
exception	B-General_Concept
,	O
then	O
it	O
is	O
thrown	O
to	O
the	O
customer	O
of	O
the	O
request	O
R	B-Language
.	O
</s>
<s>
If	O
it	O
does	O
not	O
already	O
have	O
a	O
response	O
,	O
then	O
R	B-Language
is	O
stored	O
in	O
the	O
queue	O
of	O
requests	O
inside	O
the	O
F	O
.	O
</s>
<s>
If	O
V	O
is	O
an	O
exception	B-General_Concept
,	O
then	O
it	O
is	O
thrown	O
to	O
the	O
customer	O
of	O
each	O
of	O
the	O
queued	O
requests	O
.	O
</s>
<s>
The	O
future	O
and/or	O
promise	O
constructs	O
were	O
first	O
implemented	O
in	O
programming	O
languages	O
such	O
as	O
MultiLisp	B-Language
and	O
Act	B-Application
1	I-Application
.	O
</s>
<s>
The	O
use	O
of	O
logic	O
variables	O
for	O
communication	O
in	O
concurrent	B-Operating_System
logic	B-Language
programming	I-Language
languages	I-Language
was	O
quite	O
similar	O
to	O
futures	O
.	O
</s>
<s>
These	O
began	O
in	O
Prolog	B-Language
with	O
Freeze	O
and	O
IC	O
Prolog	B-Language
,	O
and	O
became	O
a	O
true	O
concurrency	B-Operating_System
primitive	O
with	O
Relational	O
Language	O
,	O
Concurrent	B-Operating_System
Prolog	B-Language
,	O
guarded	O
Horn	B-Application
clauses	I-Application
(	O
GHC	O
)	O
,	O
Parlog	B-Language
,	O
Strand	B-Language
,	O
Vulcan	O
,	O
Janus	B-Language
,	O
Oz-Mozart	B-Language
,	O
Flow	B-Language
Java	I-Language
,	O
and	O
Alice	B-Language
ML	I-Language
.	O
</s>
<s>
The	O
single-assignment	O
I-var	B-Operating_System
from	O
dataflow	B-Application
programming	I-Application
languages	I-Application
,	O
originating	O
in	O
Id	B-Language
and	O
included	O
in	O
Reppy	O
's	O
Concurrent	B-Language
ML	I-Language
,	O
is	O
much	O
like	O
the	O
concurrent	B-Operating_System
logic	I-Operating_System
variable	I-Operating_System
.	O
</s>
<s>
The	O
promise	O
pipelining	O
technique	O
(	O
using	O
futures	O
to	O
overcome	O
latency	O
)	O
was	O
invented	O
by	O
Barbara	O
Liskov	O
and	O
Liuba	O
Shrira	O
in	O
1988	O
,	O
and	O
independently	O
by	O
Mark	O
S	O
.	O
Miller	O
,	O
Dean	O
Tribble	O
and	O
Rob	O
Jellinghaus	O
in	O
the	O
context	O
of	O
Project	B-Protocol
Xanadu	I-Protocol
circa	O
1989	O
.	O
</s>
<s>
The	O
term	O
promise	O
was	O
coined	O
by	O
Liskov	O
and	O
Shrira	O
,	O
although	O
they	O
referred	O
to	O
the	O
pipelining	O
mechanism	O
by	O
the	O
name	O
call-stream	B-Operating_System
,	O
which	O
is	O
now	O
rarely	O
used	O
.	O
</s>
<s>
Both	O
the	O
design	O
described	O
in	O
Liskov	O
and	O
Shrira	O
's	O
paper	O
,	O
and	O
the	O
implementation	O
of	O
promise	O
pipelining	O
in	O
Xanadu	O
,	O
had	O
the	O
limit	O
that	O
promise	O
values	O
were	O
not	O
first-class	O
:	O
an	O
argument	O
to	O
,	O
or	O
the	O
value	O
returned	O
by	O
a	O
call	O
or	O
send	O
could	O
not	O
directly	O
be	O
a	O
promise	O
(	O
so	O
the	O
example	O
of	O
promise	O
pipelining	O
given	O
earlier	O
,	O
which	O
uses	O
a	O
promise	O
for	O
the	O
result	O
of	O
one	O
send	O
as	O
an	O
argument	O
to	O
another	O
,	O
would	O
not	O
have	O
been	O
directly	O
expressible	O
in	O
the	O
call-stream	B-Operating_System
design	O
or	O
in	O
the	O
Xanadu	O
implementation	O
)	O
.	O
</s>
<s>
It	O
seems	O
that	O
promises	O
and	O
call-streams	B-Operating_System
were	O
never	O
implemented	O
in	O
any	O
public	O
release	O
of	O
Argus	B-Language
,	O
the	O
programming	O
language	O
used	O
in	O
the	O
Liskov	O
and	O
Shrira	O
paper	O
.	O
</s>
<s>
Argus	B-Language
development	O
stopped	O
around	O
1988	O
.	O
</s>
<s>
The	O
later	O
implementations	O
in	O
Joule	B-Language
and	O
E	B-Language
support	O
fully	O
first-class	O
promises	O
and	O
resolvers	B-Operating_System
.	O
</s>
<s>
After	O
2000	O
,	O
a	O
major	O
revival	O
of	O
interest	O
in	O
futures	B-Operating_System
and	I-Operating_System
promises	I-Operating_System
occurred	O
,	O
due	O
to	O
their	O
use	O
in	O
responsiveness	B-Application
of	O
user	O
interfaces	O
,	O
and	O
in	O
web	O
development	O
,	O
due	O
to	O
the	O
request	B-Protocol
–	I-Protocol
response	I-Protocol
model	O
of	O
message-passing	O
.	O
</s>
<s>
Several	O
mainstream	O
languages	O
now	O
have	O
language	O
support	O
for	O
futures	B-Operating_System
and	I-Operating_System
promises	I-Operating_System
,	O
most	O
notably	O
popularized	O
by	O
FutureTask	O
in	O
Java	B-Language
5	O
(	O
announced	O
2004	O
)	O
and	O
the	O
async/await	O
constructions	O
in	O
.NET	B-Application
4.5	O
(	O
announced	O
2010	O
,	O
released	O
2012	O
)	O
largely	O
inspired	O
by	O
the	O
asynchronous	O
workflows	O
of	O
F#	O
,	O
which	O
dates	O
to	O
2007	O
.	O
</s>
<s>
This	O
has	O
subsequently	O
been	O
adopted	O
by	O
other	O
languages	O
,	O
notably	O
Dart	B-Language
(	O
2014	O
)	O
,	O
Python	B-Language
(	O
2015	O
)	O
,	O
Hack	O
(	O
HHVM	O
)	O
,	O
and	O
drafts	O
of	O
ECMAScript	B-Language
7	O
(	O
JavaScript	B-Language
)	O
,	O
Scala	B-Application
,	O
and	O
C++	B-Language
(	O
2011	O
)	O
.	O
</s>
<s>
Some	O
programming	O
languages	O
are	O
supporting	O
futures	O
,	O
promises	O
,	O
concurrent	B-Operating_System
logic	I-Operating_System
variables	I-Operating_System
,	O
dataflow	B-Operating_System
variables	I-Operating_System
,	O
or	O
I-vars	B-Operating_System
,	O
either	O
by	O
direct	O
language	O
support	O
or	O
in	O
the	O
standard	O
library	O
.	O
</s>
<s>
For	O
Common	B-Language
Lisp	I-Language
:	O
</s>
<s>
For	O
C++	B-Language
:	O
</s>
<s>
For	O
JavaScript	B-Language
:	O
</s>
<s>
For	O
Java	B-Language
:	O
</s>
<s>
For	O
Lua	B-Language
:	O
</s>
<s>
For	O
Objective-C	B-Language
:	O
MAFuture	O
,	O
RXPromise	O
,	O
ObjC-CollapsingFutures	O
,	O
PromiseKit	O
,	O
objc-promise	O
,	O
OAPromise	O
,	O
</s>
<s>
For	O
Python	B-Language
:	O
</s>
<s>
For	O
R	B-Language
:	O
</s>
<s>
For	O
Ruby	B-Language
:	O
</s>
<s>
For	O
Rust	B-Application
:	O
</s>
<s>
For	O
Scala	B-Application
:	O
</s>
<s>
For	O
Swift	B-Application
:	O
</s>
<s>
Futures	O
can	O
be	O
implemented	O
in	O
coroutines	B-Architecture
or	O
generators	O
,	O
resulting	O
in	O
the	O
same	O
evaluation	B-Language
strategy	I-Language
(	O
e.g.	O
,	O
cooperative	O
multitasking	O
or	O
lazy	O
evaluation	O
)	O
.	O
</s>
<s>
Futures	O
can	O
easily	O
be	O
implemented	O
in	O
channels	B-Operating_System
:	O
a	O
future	O
is	O
a	O
one-element	O
channel	O
,	O
and	O
a	O
promise	O
is	O
a	O
process	O
that	O
sends	O
to	O
the	O
channel	O
,	O
fulfilling	O
the	O
future	O
.	O
</s>
<s>
This	O
allows	O
futures	O
to	O
be	O
implemented	O
in	O
concurrent	B-Operating_System
programming	O
languages	O
with	O
support	O
for	O
channels	B-Operating_System
,	O
such	O
as	O
CSP	O
and	O
Go	B-Application
.	O
</s>
