1 ! Copyright (C) 2005 Chris Double. All Rights Reserved.
2 ! See http://factorcode.org/license.txt for BSD license.
4 USING: kernel concurrency threads vectors arrays sequences namespaces
5 test errors dlists strings math words match ;
11 "junk" over dlist-push-end
12 20 over dlist-push-end
13 [ string? ] swap dlist-pop?
19 "junk" over dlist-push-end
20 20 over dlist-push-end
21 [ string? ] over dlist-pop? drop
28 "junk" over dlist-push-end
29 20 over dlist-push-end
30 [ integer? ] over dlist-pop? drop
31 [ integer? ] over dlist-pop? drop
38 "junk" over dlist-push-end
39 20 over dlist-push-end
40 [ string? ] swap dlist-pred?
46 "junk" over dlist-push-end
47 20 over dlist-push-end
48 [ integer? ] swap dlist-pred?
54 "junk" over dlist-push-end
55 20 over dlist-push-end
56 [ string? ] over dlist-pop? drop
57 [ string? ] swap dlist-pred?
63 2dup [ mailbox-get swap push ] curry curry in-thread
64 2dup [ mailbox-get swap push ] curry curry in-thread
65 2dup [ mailbox-get swap push ] curry curry in-thread
74 2dup [ [ integer? ] swap mailbox-get? swap push ] curry curry in-thread
75 2dup [ [ integer? ] swap mailbox-get? swap push ] curry curry in-thread
76 2dup [ [ integer? ] swap mailbox-get? swap push ] curry curry in-thread
82 [ V{ 1 "junk" 3 "junk2" } [ 456 ] ] [
85 2dup [ [ integer? ] swap mailbox-get? swap push ] curry curry in-thread
86 2dup [ [ integer? ] swap mailbox-get? swap push ] curry curry in-thread
87 2dup [ [ string? ] swap mailbox-get? swap push ] curry curry in-thread
88 2dup [ [ string? ] swap mailbox-get? swap push ] curry curry in-thread
90 "junk" over mailbox-put
91 [ 456 ] over mailbox-put
93 "junk2" over mailbox-put
98 [ self ] "test" with-process
105 { { ?from ?tag _ } [ ?tag "received" 2array ?from send ] }
108 "sent" swap send-synchronous
116 [ 2 mod 0 = not ] receive-if
132 [ 50 ] future ?future
138 2dup [ ?promise swap push ] curry curry spawn drop
139 2dup [ ?promise swap push ] curry curry spawn drop
140 2dup [ ?promise swap push ] curry curry spawn drop
149 : counter ( value -- )
151 { { increment ?value } [ ?value + counter ] }
152 { { decrement ?value } [ ?value - counter ] }
153 { { value ?from } [ dup ?from send counter ] }
158 { increment 10 } over send
159 { decrement 15 } over send
160 [ value , self , ] { } make swap send