1 ! Copyright (C) 2008, 2011 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: continuations init io.backend kernel namespaces threads ;
6 ! The Cocoa and Gtk UI backend stops the I/O thread and takes
8 SYMBOL: io-thread-running?
10 TUPLE: io-thread < thread ;
12 : <io-thread> ( -- thread )
14 [ io-thread-running? get-global ]
15 [ sleep-time io-multiplex yield ]
19 io-thread new-thread ;
21 M: io-thread error-in-thread die drop rethrow ;
23 : start-io-thread ( -- )
24 t io-thread-running? set-global
27 : stop-io-thread ( -- )
28 f io-thread-running? set-global ;
30 [ start-io-thread ] "io.thread" add-startup-hook