diff --git a/basis/concurrency/mailboxes/mailboxes-tests.factor b/basis/concurrency/mailboxes/mailboxes-tests.factor index 56d579d6c7..3435a01455 100644 --- a/basis/concurrency/mailboxes/mailboxes-tests.factor +++ b/basis/concurrency/mailboxes/mailboxes-tests.factor @@ -42,40 +42,6 @@ IN: concurrency.mailboxes.tests mailbox-get ] unit-test - "m" set - -1 "c" set -1 "d" set - -[ - "c" get await - [ "m" get mailbox-get drop ] - [ drop "d" get count-down ] recover -] "Mailbox close test" spawn drop - -[ ] [ "c" get count-down ] unit-test -[ ] [ "m" get dispose ] unit-test -[ ] [ "d" get 5 seconds await-timeout ] unit-test - -[ ] [ "m" get dispose ] unit-test - - "m" set - -1 "c" set -1 "d" set - -[ - "c" get await - "m" get wait-for-close - "d" get count-down -] "Mailbox close test" spawn drop - -[ ] [ "c" get count-down ] unit-test -[ ] [ "m" get dispose ] unit-test -[ ] [ "d" get 5 seconds await-timeout ] unit-test - -[ ] [ "m" get dispose ] unit-test - [ { "foo" "bar" } ] [ "foo" over mailbox-put @@ -86,4 +52,3 @@ IN: concurrency.mailboxes.tests [ 1 seconds mailbox-get-timeout ] [ wait-timeout? ] must-fail-with - diff --git a/basis/concurrency/mailboxes/mailboxes.factor b/basis/concurrency/mailboxes/mailboxes.factor index 7834a2a3e1..06da3b34a6 100644 --- a/basis/concurrency/mailboxes/mailboxes.factor +++ b/basis/concurrency/mailboxes/mailboxes.factor @@ -1,17 +1,17 @@ -! Copyright (C) 2005, 2008 Chris Double, Slava Pestov. +! Copyright (C) 2005, 2010 Chris Double, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: dlists deques threads sequences continuations -destructors namespaces math quotations words kernel -arrays assocs init system concurrency.conditions accessors -debugger debugger.threads locals fry ; +USING: dlists deques threads sequences continuations namespaces +math quotations words kernel arrays assocs init system +concurrency.conditions accessors debugger debugger.threads +locals fry ; IN: concurrency.mailboxes -TUPLE: mailbox < disposable threads data ; - -M: mailbox dispose* threads>> notify-all ; +TUPLE: mailbox threads data ; : ( -- mailbox ) - mailbox new-disposable >>threads >>data ; + mailbox new + >>threads + >>data ; : mailbox-empty? ( mailbox -- bool ) data>> deque-empty? ; @@ -24,14 +24,12 @@ M: mailbox dispose* threads>> notify-all ; [ threads>> ] dip "mailbox" wait ; :: block-unless-pred ( mailbox timeout pred: ( message -- ? ) -- ) - mailbox check-disposed mailbox data>> pred dlist-any? [ mailbox timeout wait-for-mailbox mailbox timeout pred block-unless-pred ] unless ; inline recursive : block-if-empty ( mailbox timeout -- mailbox ) - over check-disposed over mailbox-empty? [ 2dup wait-for-mailbox block-if-empty ] [