diff --git a/extra/concurrency/conditions/conditions.factor b/extra/concurrency/conditions/conditions.factor index 359ceaa9ae..b10aded671 100755 --- a/extra/concurrency/conditions/conditions.factor +++ b/extra/concurrency/conditions/conditions.factor @@ -8,7 +8,7 @@ IN: concurrency.conditions dup dlist-empty? [ drop ] [ pop-back resume-now ] if ; : notify-all ( dlist -- ) - [ resume-now ] dlist-slurp yield ; + [ resume-now ] dlist-slurp ; : queue-timeout ( queue timeout -- alarm ) #! Add an alarm which removes the current thread from the diff --git a/extra/ui/gadgets/gadgets.factor b/extra/ui/gadgets/gadgets.factor index 3db3b9c270..c6cb5bc14a 100755 --- a/extra/ui/gadgets/gadgets.factor +++ b/extra/ui/gadgets/gadgets.factor @@ -2,9 +2,18 @@ ! See http://factorcode.org/license.txt for BSD license. USING: arrays hashtables kernel models math namespaces sequences quotations math.vectors combinators sorting vectors dlists -models threads ; +models threads concurrency.messaging ; 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 ; C: rect @@ -178,10 +187,6 @@ M: array gadget-text* : 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-later ( gadget -- ) diff --git a/extra/ui/tools/listener/listener.factor b/extra/ui/tools/listener/listener.factor index d828471609..7617b0f32d 100755 --- a/extra/ui/tools/listener/listener.factor +++ b/extra/ui/tools/listener/listener.factor @@ -133,7 +133,7 @@ M: stack-display tool-scroller : restart-listener ( listener -- ) dup com-end dup clear-output - [ init-namespaces listener-thread ] curry + [ listener-thread ] curry "Listener" spawn drop ; : init-listener ( listener -- ) diff --git a/extra/ui/ui.factor b/extra/ui/ui.factor index 276bd3ec2a..1bd84df518 100755 --- a/extra/ui/ui.factor +++ b/extra/ui/ui.factor @@ -4,7 +4,7 @@ USING: arrays assocs io kernel math models namespaces prettyprint dlists sequences threads sequences words debugger ui.gadgets ui.gadgets.worlds ui.gadgets.tracks ui.gestures ui.backend ui.render continuations init combinators -hashtables ; +hashtables concurrency.messaging ; IN: ui ! Assoc mapping aliens to gadgets @@ -142,16 +142,14 @@ SYMBOL: ui-hook t \ ui-running set-global [ f \ ui-running set-global ] [ ] cleanup ; inline -: ui-thread-running? ( -- ? ) - ui-thread get-global self eq? \ ui-running get-global and ; - : update-ui-loop ( -- ) - ui-thread-running? - [ [ update-ui ] ui-try f sleep-until update-ui-loop ] when ; + receive { { "notify" [ ] } { "stop" [ stop ] } } case + [ update-ui ] ui-try + update-ui-loop ; : start-ui-thread ( -- ) - [ self ui-thread set-global update-ui-loop ] - "UI update" spawn drop ; + [ update-ui-loop ] + "UI update" spawn ui-thread set-global ; : open-world-window ( world -- ) dup pref-dim over set-gadget-dim dup relayout graft ;