]> gitweb.factorcode.org Git - factor.git/blob - basis/io/thread/thread.factor
change add-init-hook to add-startup-hook, new add-shutdown-hook word
[factor.git] / basis / io / thread / thread.factor
1 ! Copyright (C) 2008 Slava Pestov.\r
2 ! See http://factorcode.org/license.txt for BSD license.\r
3 USING: threads io.backend namespaces init math kernel ;\r
4 IN: io.thread\r
5 \r
6 ! The Cocoa UI backend stops the I/O thread and takes over\r
7 ! completely.\r
8 SYMBOL: io-thread-running?\r
9 \r
10 : io-thread ( -- )\r
11     sleep-time io-multiplex yield ;\r
12 \r
13 : start-io-thread ( -- )\r
14     [ [ io-thread-running? get-global ] [ io-thread ] while ]\r
15     "I/O wait" spawn drop ;\r
16 \r
17 [\r
18     t io-thread-running? set-global\r
19     start-io-thread\r
20 ] "io.thread" add-startup-hook\r