Handbook
Glossary
exchange ( obj exchanger -- newobj )
Object exchange points
Prev:
<exchanger> ( -- exchanger )
Vocabulary
concurrency
.
exchangers
Inputs
obj
an
object
exchanger
an
exchanger
Outputs
newobj
an
object
Word description
Waits for another thread to call
exchange
on the same exchanger. The thread's call to
exchange
returns with
obj
on the stack, and the object passed to
exchange
by the other thread is left on the current's thread stack as
newobj
.
Definition
USING:
accessors
boxes
kernel
threads
;
IN:
concurrency.exchangers
:
exchange
( obj exchanger -- newobj )
dup
thread>>
occupied>>
[
dup
object>>
box>
[
thread>>
box>
resume-with
]
dip
]
[
[
object>>
>box
]
keep
[
self
]
dip
thread>>
>box
"exchange"
suspend
]
if
;