factor/basis/io/thread/thread.factor

24 lines
611 B
Factor
Raw Normal View History

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