diff --git a/library/bootstrap/boot-stage3.factor b/library/bootstrap/boot-stage3.factor index 4097bd1dd3..f4450b7d9a 100644 --- a/library/bootstrap/boot-stage3.factor +++ b/library/bootstrap/boot-stage3.factor @@ -120,8 +120,8 @@ t [ "/library/ui/editors.factor" "/library/ui/menus.factor" "/library/ui/presentations.factor" - "/library/ui/tiles.factor" "/library/ui/panes.factor" + "/library/ui/tiles.factor" "/library/ui/dialogs.factor" "/library/ui/inspector.factor" "/library/ui/init-world.factor" diff --git a/library/in-thread.factor b/library/in-thread.factor deleted file mode 100644 index 392e7404bb..0000000000 --- a/library/in-thread.factor +++ /dev/null @@ -1,18 +0,0 @@ -! Copyright (C) 2004, 2005 Slava Pestov. -! See http://factor.sf.net/license.txt for BSD license. -IN: threads USING: errors io-internals kernel lists ; - -: in-thread ( quot -- ) - #! Execute a quotation in a co-operative thread. The - #! quotation begins executing immediately, and execution - #! after the 'in-thread' call in the original thread - #! resumes when the quotation yields, either due to blocking - #! I/O or an explicit call to 'yield'. - [ - schedule-thread - ! Clear stacks since we never go up from this point - [ ] set-catchstack - { } set-callstack - try - stop - ] callcc0 drop ; diff --git a/library/threads.factor b/library/threads.factor index 86fb457043..bcddc33257 100644 --- a/library/threads.factor +++ b/library/threads.factor @@ -2,8 +2,7 @@ ! Copyright (C) 2005 Mackenzie Straight. ! See http://factor.sf.net/license.txt for BSD license. IN: threads -USING: errors io-internals kernel kernel-internals lists -namespaces ; +USING: errors kernel kernel-internals lists namespaces ; ! Core of the multitasker. Used by io-internals.factor and ! in-thread.factor. diff --git a/library/ui/world.factor b/library/ui/world.factor index 648e3f2ec3..2923a76a1f 100644 --- a/library/ui/world.factor +++ b/library/ui/world.factor @@ -1,8 +1,9 @@ ! Copyright (C) 2005 Slava Pestov. ! See http://factor.sf.net/license.txt for BSD license. IN: gadgets -USING: alien errors generic kernel lists math memory namespaces -prettyprint sdl sequences stdio strings threads ; +USING: alien errors generic kernel lists math +memory namespaces prettyprint sdl sequences stdio strings +threads ; ! The world gadget is the top level gadget that all (visible) ! gadgets are contained in. The current world is stored in the @@ -43,10 +44,12 @@ DEFER: handle-event drop f ] ifte ; +: next-event ( -- event ) dup SDL_PollEvent ; + : run-world ( -- ) #! Keep polling for events until there are no more events in #! the queue; then block for the next event. - dup SDL_PollEvent [ + next-event [ [ handle-event ] in-thread drop run-world ] [ drop world get world-step [ yield run-world ] when diff --git a/library/unix/io.factor b/library/unix/io.factor index dc0677ea2a..4296203cce 100644 --- a/library/unix/io.factor +++ b/library/unix/io.factor @@ -355,6 +355,9 @@ M: writer stream-close ( stream -- ) : ( infd outfd flush? -- stream ) >r >r r> r> ; +: idle-io-task ( -- ) + [ schedule-thread 10 io-multiplex ] callcc0 idle-io-task ; + USE: stdio : init-io ( -- ) @@ -363,12 +366,5 @@ USE: stdio global [ io-tasks set 0 1 t stdio set - ] bind ; - -IN: threads - -: stop ( -- ) - #! If there is a quotation in the run queue, call it, - #! otherwise wait for I/O. - pending-io? [ 10 io-multiplex ] when - next-thread [ call ] [ -1 io-multiplex stop ] ifte* ; + ] bind + [ idle-io-task ] in-thread ;