2005-01-29 14:18:28 -05:00
|
|
|
! Copyright (C) 2004, 2005 Slava Pestov.
|
|
|
|
! See http://factor.sf.net/license.txt for BSD license.
|
|
|
|
IN: threads USING: errors io-internals kernel lists ;
|
2004-08-22 01:46:26 -04:00
|
|
|
|
|
|
|
: in-thread ( quot -- )
|
|
|
|
#! Execute a quotation in a co-operative thread. The
|
|
|
|
#! quotation begins executing immediately, and execution
|
|
|
|
#! after the 'in-thread' call in the original thread
|
|
|
|
#! resumes when the quotation yields, either due to blocking
|
|
|
|
#! I/O or an explicit call to 'yield'.
|
|
|
|
[
|
|
|
|
schedule-thread
|
2004-11-13 18:07:18 -05:00
|
|
|
! Clear stacks since we never go up from this point
|
2004-11-25 23:14:17 -05:00
|
|
|
[ ] set-catchstack
|
2004-11-13 18:07:18 -05:00
|
|
|
{ } set-callstack
|
2004-12-25 21:28:47 -05:00
|
|
|
try
|
2005-04-22 00:22:36 -04:00
|
|
|
stop
|
2004-08-22 01:46:26 -04:00
|
|
|
] callcc0 drop ;
|