db4
Slava Pestov 2008-02-25 17:19:34 -06:00
parent 071d800c10
commit 438f00a6a5
4 changed files with 18 additions and 15 deletions

View File

@ -8,7 +8,7 @@ IN: concurrency.conditions
dup dlist-empty? [ drop ] [ pop-back resume-now ] if ; dup dlist-empty? [ drop ] [ pop-back resume-now ] if ;
: notify-all ( dlist -- ) : notify-all ( dlist -- )
[ resume-now ] dlist-slurp yield ; [ resume-now ] dlist-slurp ;
: queue-timeout ( queue timeout -- alarm ) : queue-timeout ( queue timeout -- alarm )
#! Add an alarm which removes the current thread from the #! Add an alarm which removes the current thread from the

View File

@ -2,9 +2,18 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: arrays hashtables kernel models math namespaces sequences USING: arrays hashtables kernel models math namespaces sequences
quotations math.vectors combinators sorting vectors dlists quotations math.vectors combinators sorting vectors dlists
models threads ; models threads concurrency.messaging ;
IN: ui.gadgets IN: ui.gadgets
SYMBOL: ui-thread
: notify-ui-thread ( -- )
self ui-thread get-global eq? [
"notify" ui-thread get-global send
] unless ;
: stop-ui-thread ( -- ) "stop" ui-thread get-global send ;
TUPLE: rect loc dim ; TUPLE: rect loc dim ;
C: <rect> rect C: <rect> rect
@ -178,10 +187,6 @@ M: array gadget-text*
: forget-pref-dim ( gadget -- ) f swap set-gadget-pref-dim ; : forget-pref-dim ( gadget -- ) f swap set-gadget-pref-dim ;
SYMBOL: ui-thread
: notify-ui-thread ( -- ) ui-thread get interrupt ;
: layout-queue ( -- queue ) \ layout-queue get ; : layout-queue ( -- queue ) \ layout-queue get ;
: layout-later ( gadget -- ) : layout-later ( gadget -- )

View File

@ -133,7 +133,7 @@ M: stack-display tool-scroller
: restart-listener ( listener -- ) : restart-listener ( listener -- )
dup com-end dup clear-output dup com-end dup clear-output
[ init-namespaces listener-thread ] curry [ listener-thread ] curry
"Listener" spawn drop ; "Listener" spawn drop ;
: init-listener ( listener -- ) : init-listener ( listener -- )

View File

@ -4,7 +4,7 @@ USING: arrays assocs io kernel math models namespaces
prettyprint dlists sequences threads sequences words prettyprint dlists sequences threads sequences words
debugger ui.gadgets ui.gadgets.worlds ui.gadgets.tracks debugger ui.gadgets ui.gadgets.worlds ui.gadgets.tracks
ui.gestures ui.backend ui.render continuations init combinators ui.gestures ui.backend ui.render continuations init combinators
hashtables ; hashtables concurrency.messaging ;
IN: ui IN: ui
! Assoc mapping aliens to gadgets ! Assoc mapping aliens to gadgets
@ -142,16 +142,14 @@ SYMBOL: ui-hook
t \ ui-running set-global t \ ui-running set-global
[ f \ ui-running set-global ] [ ] cleanup ; inline [ f \ ui-running set-global ] [ ] cleanup ; inline
: ui-thread-running? ( -- ? )
ui-thread get-global self eq? \ ui-running get-global and ;
: update-ui-loop ( -- ) : update-ui-loop ( -- )
ui-thread-running? receive { { "notify" [ ] } { "stop" [ stop ] } } case
[ [ update-ui ] ui-try f sleep-until update-ui-loop ] when ; [ update-ui ] ui-try
update-ui-loop ;
: start-ui-thread ( -- ) : start-ui-thread ( -- )
[ self ui-thread set-global update-ui-loop ] [ update-ui-loop ]
"UI update" spawn drop ; "UI update" spawn ui-thread set-global ;
: open-world-window ( world -- ) : open-world-window ( world -- )
dup pref-dim over set-gadget-dim dup relayout graft ; dup pref-dim over set-gadget-dim dup relayout graft ;