parent
3e40ab714e
commit
6de2fc5399
|
@ -10,39 +10,39 @@ IN: temporary
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
{ V{ 10 } } [
|
{ V{ 10 } } [
|
||||||
V{ } clone <channel>
|
V{ } clone <channel>
|
||||||
[ from swap push ] in-thread
|
[ from swap push ] in-thread
|
||||||
10 swap to
|
10 swap to
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
{ 20 } [
|
{ 20 } [
|
||||||
<channel>
|
<channel>
|
||||||
[ 20 swap to ] in-thread
|
[ 20 swap to ] in-thread
|
||||||
from
|
from
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
{ V{ 1 2 3 4 } } [
|
{ V{ 1 2 3 4 } } [
|
||||||
V{ } clone <channel>
|
V{ } clone <channel>
|
||||||
[ from swap push ] in-thread
|
[ from swap push ] in-thread
|
||||||
[ from swap push ] in-thread
|
[ from swap push ] in-thread
|
||||||
[ from swap push ] in-thread
|
[ from swap push ] in-thread
|
||||||
[ from swap push ] in-thread
|
[ from swap push ] in-thread
|
||||||
4 over to
|
4 over to
|
||||||
2 over to
|
2 over to
|
||||||
1 over to
|
1 over to
|
||||||
3 swap to
|
3 swap to
|
||||||
[ <=> ] sort
|
natural-sort
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
{ V{ 1 2 4 9 } } [
|
{ V{ 1 2 4 9 } } [
|
||||||
V{ } clone <channel>
|
V{ } clone <channel>
|
||||||
[ 4 swap to ] in-thread
|
[ 4 swap to ] in-thread
|
||||||
[ 2 swap to ] in-thread
|
[ 2 swap to ] in-thread
|
||||||
[ 1 swap to ] in-thread
|
[ 1 swap to ] in-thread
|
||||||
[ 9 swap to ] in-thread
|
[ 9 swap to ] in-thread
|
||||||
2dup from swap push
|
2dup from swap push
|
||||||
2dup from swap push
|
2dup from swap push
|
||||||
2dup from swap push
|
2dup from swap push
|
||||||
dupd from swap push
|
dupd from swap push
|
||||||
[ <=> ] sort
|
natural-sort
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
!
|
!
|
||||||
! Channels - based on ideas from newsqueak
|
! Channels - based on ideas from newsqueak
|
||||||
USING: kernel sequences threads continuations random math ;
|
USING: kernel sequences sequences.lib threads continuations random math ;
|
||||||
IN: channels
|
IN: channels
|
||||||
|
|
||||||
TUPLE: channel receivers senders ;
|
TUPLE: channel receivers senders ;
|
||||||
|
@ -15,9 +15,6 @@ GENERIC: from ( channel -- value )
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
: delete-random ( seq -- value )
|
|
||||||
[ length random ] keep [ nth ] 2keep delete-nth ;
|
|
||||||
|
|
||||||
: wait ( channel -- )
|
: wait ( channel -- )
|
||||||
[ channel-senders push stop ] curry callcc0 ;
|
[ channel-senders push stop ] curry callcc0 ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue