From bb45fa93a713356a27560e5ac53cfee6b87ea6a8 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 12 Dec 2008 23:56:19 -0600 Subject: [PATCH] Add a way to stop the io thread --- basis/io/thread/thread.factor | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/basis/io/thread/thread.factor b/basis/io/thread/thread.factor index fe86ba9e3d..7589d4918e 100644 --- a/basis/io/thread/thread.factor +++ b/basis/io/thread/thread.factor @@ -1,14 +1,20 @@ ! 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 -USING: threads io.backend namespaces init math ; + +! 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 t ] - "I/O wait" spawn-server - \ io-thread set-global ; + [ [ io-thread-running? get-global ] [ io-thread ] [ ] while ] + "I/O wait" spawn drop ; -[ start-io-thread ] "io.thread" add-init-hook +[ + t io-thread-running? set-global + start-io-thread +] "io.thread" add-init-hook