new accessors

db4
Doug Coleman 2008-08-29 16:18:09 -05:00
parent 44ad8b5f3f
commit 9febce42e6
2 changed files with 6 additions and 6 deletions

View File

@ -1,13 +1,13 @@
! 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 ;
continuations accessors ;
IN: concurrency.futures
: future ( quot -- future )
<promise> [
[ [ >r call r> fulfill ] 2curry "Future" ] keep
promise-mailbox spawn-linked-to drop
mailbox>> spawn-linked-to drop
] keep ; inline
: ?future-timeout ( future timeout -- value )

View File

@ -1,6 +1,6 @@
! Copyright (C) 2005, 2008 Chris Double, Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: concurrency.mailboxes kernel continuations ;
USING: accessors concurrency.mailboxes kernel continuations ;
IN: concurrency.promises
TUPLE: promise mailbox ;
@ -9,17 +9,17 @@ TUPLE: promise mailbox ;
<mailbox> promise boa ;
: promise-fulfilled? ( promise -- ? )
promise-mailbox mailbox-empty? not ;
mailbox>> mailbox-empty? not ;
: fulfill ( value promise -- )
dup promise-fulfilled? [
"Promise already fulfilled" throw
] [
promise-mailbox mailbox-put
mailbox>> mailbox-put
] if ;
: ?promise-timeout ( promise timeout -- result )
>r promise-mailbox r> block-if-empty mailbox-peek ;
>r mailbox>> r> block-if-empty mailbox-peek ;
: ?promise ( promise -- result )
f ?promise-timeout ;