factor/basis/io/thread/thread.factor

24 lines
611 B
Factor

! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: threads io.backend namespaces init math kernel ;
IN: io.thread
! The Cocoa UI backend stops the I/O thread and takes over
! completely.
SYMBOL: io-thread-running?
: io-thread ( -- )
sleep-time io-multiplex yield ;
: start-io-thread ( -- )
[ [ io-thread-running? get-global ] [ io-thread ] while ]
"I/O wait" spawn drop ;
: stop-io-thread ( -- )
f io-thread-running? set-global ;
[
t io-thread-running? set-global
start-io-thread
] "io.thread" add-startup-hook