concurrency.mailboxes: simplify mailbox-get-all-timeout.

factor-shell
John Benediktsson 2018-01-20 11:58:52 -08:00
parent 3b78ec7b6f
commit f25d7313d6
1 changed files with 3 additions and 7 deletions

View File

@ -1,8 +1,7 @@
! Copyright (C) 2005, 2010 Chris Double, Slava Pestov. ! Copyright (C) 2005, 2010 Chris Double, Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: dlists deques threads sequences continuations namespaces USING: accessors concurrency.conditions continuations deques
math quotations words kernel arrays assocs init system dlists fry kernel locals sequences threads vocabs.loader ;
concurrency.conditions accessors locals fry vocabs.loader ;
IN: concurrency.mailboxes IN: concurrency.mailboxes
TUPLE: mailbox { threads dlist } { data dlist } ; TUPLE: mailbox { threads dlist } { data dlist } ;
@ -48,10 +47,7 @@ M: mailbox mailbox-get-timeout block-if-empty data>> pop-back ;
f mailbox-get-timeout ; inline f mailbox-get-timeout ; inline
: mailbox-get-all-timeout ( mailbox timeout -- array ) : mailbox-get-all-timeout ( mailbox timeout -- array )
block-if-empty block-if-empty data>> [ ] collector [ slurp-deque ] dip ;
[ dup mailbox-empty? not ]
[ dup data>> pop-back ]
produce nip ;
: mailbox-get-all ( mailbox -- array ) : mailbox-get-all ( mailbox -- array )
f mailbox-get-all-timeout ; f mailbox-get-all-timeout ;