Fix another bug with futures
parent
0e0a1fb244
commit
ef63333980
|
@ -134,3 +134,8 @@ SYMBOL: value
|
||||||
[ 3 ] future
|
[ 3 ] future
|
||||||
dup ?future swap ?future
|
dup ?future swap ?future
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
! Another race
|
||||||
|
[ 3 ] [
|
||||||
|
[ 3 yield ] future ?future
|
||||||
|
] unit-test
|
|
@ -273,14 +273,14 @@ TUPLE: future value processes ;
|
||||||
|
|
||||||
: future ( quot -- future )
|
: future ( quot -- future )
|
||||||
#! Spawn a process to call the quotation and immediately return.
|
#! Spawn a process to call the quotation and immediately return.
|
||||||
\ future construct-empty [
|
f V{ } clone \ future construct-boa [
|
||||||
[
|
[
|
||||||
>r [ t 2array ] compose [ f 2array ] recover r>
|
>r [ t 2array ] compose [ f 2array ] recover r>
|
||||||
notify-future
|
notify-future
|
||||||
] 2curry spawn drop
|
] 2curry spawn drop
|
||||||
] keep ;
|
] keep ;
|
||||||
|
|
||||||
: ?future ( future -- result )
|
: ?future ( future -- result )
|
||||||
#! Block the process until the future has completed and then
|
#! Block the process until the future has completed and then
|
||||||
#! place the result on the stack. Return the result
|
#! place the result on the stack. Return the result
|
||||||
#! immediately if the future has completed.
|
#! immediately if the future has completed.
|
||||||
|
|
Loading…
Reference in New Issue