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.
! See http://factorcode.org/license.txt for BSD license.
USING: dlists deques threads sequences continuations namespaces
math quotations words kernel arrays assocs init system
concurrency.conditions accessors locals fry vocabs.loader ;
USING: accessors concurrency.conditions continuations deques
dlists fry kernel locals sequences threads vocabs.loader ;
IN: concurrency.mailboxes
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
: mailbox-get-all-timeout ( mailbox timeout -- array )
block-if-empty
[ dup mailbox-empty? not ]
[ dup data>> pop-back ]
produce nip ;
block-if-empty data>> [ ] collector [ slurp-deque ] dip ;
: mailbox-get-all ( mailbox -- array )
f mailbox-get-all-timeout ;