]> gitweb.factorcode.org Git - factor.git/commitdiff
concurrency.mailboxes: simplify mailbox-get-all-timeout.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sat, 20 Jan 2018 19:58:52 +0000 (11:58 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sat, 20 Jan 2018 19:58:52 +0000 (11:58 -0800)
basis/concurrency/mailboxes/mailboxes.factor

index 82ebe8631815b85e3c6e6737023c0d70a2d111a5..3e9a56b56cb17ee5675d431d7c1f2ed48c61be55 100755 (executable)
@@ -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 ;