]> gitweb.factorcode.org Git - factor.git/commitdiff
Add a way to stop the io thread
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 13 Dec 2008 05:56:19 +0000 (23:56 -0600)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 13 Dec 2008 05:56:19 +0000 (23:56 -0600)
basis/io/thread/thread.factor

index fe86ba9e3dbe996a0c065c3cbc7f5c3d39283c36..7589d4918ec29fff8fe0231269b201b9d8a48713 100644 (file)
@@ -1,14 +1,20 @@
 ! Copyright (C) 2008 Slava Pestov.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
+USING: threads io.backend namespaces init math kernel ;\r
 IN: io.thread\r
-USING: threads io.backend namespaces init math ;\r
+\r
+! The Cocoa UI backend stops the I/O thread and takes over\r
+! completely.\r
+SYMBOL: io-thread-running?\r
 \r
 : io-thread ( -- )\r
     sleep-time io-multiplex yield ;\r
 \r
 : start-io-thread ( -- )\r
-    [ io-thread t ]\r
-    "I/O wait" spawn-server\r
-    \ io-thread set-global ;\r
+    [ [ io-thread-running? get-global ] [ io-thread ] [ ] while ]\r
+    "I/O wait" spawn drop ;\r
 \r
-[ start-io-thread ] "io.thread" add-init-hook\r
+[\r
+    t io-thread-running? set-global\r
+    start-io-thread\r
+] "io.thread" add-init-hook\r