diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 1335714b20..055a657fb7 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -1,52 +1,26 @@ -- unix i/o: problems with passing f to syscalls - if a primitive throws an error, :c doesn't show the call frame there - "benchmark/help": without a yield UI runs out of memory -- x11 title bars are funny + + httpd: - outliners don't work - browser responder doesn't work - fix remaining HTML stream issues - update for file style prop becoming presented -- fix this: - - [ 1 2 3 4 5 6 7 8 9 10 10 10 10 10 10 10 10 10 10 11 11 11 113 ] . -[ 1 2 3 4 5 6 7 8 9 10 10 10 10 10 10 10 10 10 10 11 11 11 113 -] - -- code walker & exceptions -- test and debug problems -- another i/o bug: on factorcode eventually all i/o times out - - bug in pound? -- factorcode httpd started using 99% CPU, but still received connections; - closing read-fds solved it -- if the listener is running a command when the image is saved, it - restores to an unresponsive gadget -- fix top level window positioning -- services do not launch if factor not running -- rollover is not updated on window focus changes -- amd64 crash -- x86 bootstrap intermittent crash -- get factor running on mac intel -- constant branch folding -- cocoa: starting the UI with +foo switches opens them as files -+ refactor style stack code so that nested styles are handled at a lower-level - - with-style & with-stream-style - - in HTML, we can nest div tags, etc - - prettyprinter's highlighting of non-leaves looks bad - - better line spacing in ui and html - related issue - -+ fix compiled gc check - - there was a performance hit, investigate - - float boxing and overflow checks need a gc check too - + io: +- unix i/o: problems with passing f to syscalls +- factorcode httpd started using 99% CPU, but still received connections; + closing read-fds solved it - gdb triggers 'mutliple i/o ops on port' error - better i/o scheduler - eg, yield in a loop starves i/o - "localhost" 50 won't fail + help: +- refactor style stack code so that nested styles are handled at a lower-level + - with-style & with-stream-style + - in HTML, we can nest div tags, etc - automatically update help graph when adding/removing articles/words - help search: - edit distance algorithm @@ -55,6 +29,15 @@ + ui: +- x11 title bars are funny +- cocoa: starting the UI with +foo switches opens them as files +- if the listener is running a command when the image is saved, it + restores to an unresponsive gadget +- fix top level window positioning +- services do not launch if factor not running +- prettyprinter's highlighting of non-leaves doesn't really work +- better line spacing in ui and html - related issue +- rollover is not updated on window focus changes - fix listener scroll to - { } H{ } [ ] tabular-output -- excess newline - multiple listener-run-files is broken @@ -72,8 +55,6 @@ - only do clipping for certain gadgets - use glRect - use complex numbers instead of arrays for co-ordinates - - decrease minimum growable size from 50 to 4 or something, to reduce - memory consumption of a gadget with one child - use vertex arrays - use display lists - reimplement tab completion @@ -85,6 +66,12 @@ + compiler/ffi: +- fix compiled gc check + - there was a performance hit, investigate + - float boxing and overflow checks need a gc check too +- amd64 crash +- get factor running on mac intel +- constant branch folding - type inference at branch merge points - free up r11, r12 as a vreg on ppc - float= on powerpc doesn't consider nans equal @@ -104,6 +91,13 @@ + misc: +- fix this: + + [ 1 2 3 4 5 6 7 8 9 10 10 10 10 10 10 10 10 10 10 11 11 11 113 ] . +[ 1 2 3 4 5 6 7 8 9 10 10 10 10 10 10 10 10 10 10 11 11 11 113 +] + +- code walker & exceptions -- test and debug problems - slice: if sequence or seq start is changed, abstraction violation - make 3.4 bits>double an error - break: perhaps use current stdio to run break listener diff --git a/doc/handbook/dataflow.facts b/doc/handbook/dataflow.facts index 37e8d60326..602f72ddba 100644 --- a/doc/handbook/dataflow.facts +++ b/doc/handbook/dataflow.facts @@ -157,7 +157,7 @@ ARTICLE: "threads" "Multitasking" { $subsection run-queue } { $subsection sleep-queue } { $subsection schedule-thread } -{ $subsection next-thread } ; +{ $subsection idle-thread } ; ARTICLE: "continuations-internals" "Continuation implementation details" "A continuation is simply a tuple holding the contents of the four stacks:" diff --git a/library/bootstrap/boot-stage2.factor b/library/bootstrap/boot-stage2.factor index c285947266..7160b1c400 100644 --- a/library/bootstrap/boot-stage2.factor +++ b/library/bootstrap/boot-stage2.factor @@ -39,9 +39,6 @@ parser sequences sequences-internals words ; "Unless you're working on the compiler, ignore the errors above." print "Not every word compiles, by design." print terpri flush - - "Building online help search index..." print flush - index-help "Initializing native I/O..." print flush "native-io" get [ init-io ] when @@ -60,6 +57,9 @@ parser sequences sequences-internals words ; compile-all ] when ] when + + "Building online help search index..." print flush + index-help [ boot diff --git a/library/threads.factor b/library/threads.factor index 57220c1d3a..bd5b884701 100644 --- a/library/threads.factor +++ b/library/threads.factor @@ -19,16 +19,23 @@ namespaces queues sequences vectors ; : sleep-time ( sorted-queue -- ms ) dup empty? [ drop 1000 ] [ peek first millis [-] ] if ; -DEFER: next-thread - -: do-sleep ( -- continuation ) - sleep-queue* dup sleep-time dup zero? - [ drop pop second ] [ nip io-multiplex next-thread ] if ; - -: next-thread ( -- continuation ) - run-queue dup queue-empty? [ drop do-sleep ] [ deque ] if ; - -: stop ( -- ) next-thread continue ; +! DEFER: next-thread +! +! : do-sleep ( -- continuation ) +! sleep-queue* dup sleep-time dup zero? +! [ drop pop second ] [ nip io-multiplex next-thread ] if ; +! +! : next-thread ( -- continuation ) +! run-queue dup queue-empty? [ drop do-sleep ] [ deque ] if ; +! +! : stop ( -- ) next-thread continue ; +! +! : init-threads ( -- ) +! global [ +! \ run-queue set +! V{ } clone \ sleep-queue set +! ] bind ; +: stop ( -- ) run-queue deque continue ; : yield ( -- ) [ schedule-thread stop ] callcc0 ; @@ -44,8 +51,18 @@ DEFER: next-thread try stop ] callcc0 drop ; +: (idle-thread) ( fast? -- ) + #! If fast, then we don't sleep, just select() + sleep-queue* dup sleep-time dup zero? + [ drop pop second schedule-thread ] + [ nip 0 ? io-multiplex ] if ; + +: idle-thread ( -- ) + #! This thread is always running. + #! If run queue is not empty, we don't sleep. + run-queue queue-empty? (idle-thread) yield idle-thread ; + : init-threads ( -- ) - global [ - \ run-queue set - V{ } clone \ sleep-queue set - ] bind ; + \ run-queue set-global + V{ } clone \ sleep-queue set-global + [ idle-thread ] in-thread ; diff --git a/library/threads.facts b/library/threads.facts index 8012f1917b..35680b3cb3 100644 --- a/library/threads.facts +++ b/library/threads.facts @@ -20,10 +20,6 @@ HELP: sleep-time "( vector -- ms )" { $values { "vector" "a sorted sleep queue" } { "ms" "a non-negative integer" } } { $description "Outputs the time until the next sleeping thread is scheduled to wake up, or -1 if there are no sleeping threads. The input must be a sorted sleep queue output by " { $link sleep-queue* } "." } ; -HELP: next-thread "( -- continuation )" -{ $values { "continuation" "a continuation" } } -{ $description "Outputs the next runnable thread. If there are no runnable threads, waits for a sleeping thread to wake up." } ; - HELP: stop "( -- )" { $description "Stops the current thread." } ; diff --git a/library/unix/io.factor b/library/unix/io.factor index 6269cdf777..4b5ac6d0cb 100644 --- a/library/unix/io.factor +++ b/library/unix/io.factor @@ -116,7 +116,7 @@ GENERIC: task-container ( task -- vector ) : handle-fd ( task -- ) dup io-task-port touch-port dup do-io-task - [ pop-callback continue ] [ drop ] if ; + [ pop-callback schedule-thread ] [ drop ] if ; : timeout? ( port -- ? ) port-cutoff dup zero? not swap millis < and ; @@ -125,7 +125,7 @@ GENERIC: task-container ( task -- vector ) [ nip dup io-task-port timeout? [ dup io-task-port "Timeout" swap report-error - nip pop-callback continue + nip pop-callback schedule-thread ] [ tuck io-task-fd swap bit-nth [ handle-fd ] [ drop ] if