factor/basis/concurrency/futures/futures.factor

18 lines
535 B
Factor
Raw Normal View History

2008-02-18 06:07:40 -05:00
! Copyright (C) 2005, 2008 Chris Double, Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: concurrency.promises concurrency.mailboxes kernel arrays
2008-08-29 17:18:09 -04:00
continuations accessors ;
2008-02-18 06:07:40 -05:00
IN: concurrency.futures
: future ( quot -- future )
<promise> [
2008-02-18 10:08:59 -05:00
[ [ >r call r> fulfill ] 2curry "Future" ] keep
2008-08-29 17:18:09 -04:00
mailbox>> spawn-linked-to drop
2008-02-18 06:07:40 -05:00
] keep ; inline
: ?future-timeout ( future timeout -- value )
?promise-timeout ?linked ;
2008-02-18 06:07:40 -05:00
: ?future ( future -- value )
?promise ?linked ;