From eeaaa729ac7e7c15f3f9e9473e4ea716f0408bb3 Mon Sep 17 00:00:00 2001 From: eknauel Date: Mon, 30 May 2005 15:21:40 +0000 Subject: [PATCH] run init-executables-completion-set! in a seperate thread --- scheme/nuit-engine.scm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/scheme/nuit-engine.scm b/scheme/nuit-engine.scm index 792c14a..12213a0 100644 --- a/scheme/nuit-engine.scm +++ b/scheme/nuit-engine.scm @@ -7,6 +7,12 @@ (begin ?do-this ... (values)) (values))))) +(define (with-lock lock thunk) + (obtain-lock lock) + (let ((val (thunk))) + (release-lock lock) + val)) + ;;This is the "heart" of NUIT. ;;In a central loop the program waits for input (with wgetch). ;;In the upper buffer simply the functionalities of scsh-ncurses: @@ -42,6 +48,7 @@ (define result-window #f) (define result-frame-window #f) +(define executable-completions-lock (make-lock)) (define executable-completions #f) (define key-control-x 24) @@ -475,8 +482,12 @@ '("/usr/bin" "/bin" "/usr/sbin" "/sbin")))) (define (init-executables-completion-set!) - (set! executable-completions - (make-completion-set-for-executables (get-path-list)))) + (spawn + (lambda () + (with-lock executable-completions-lock + (lambda() + (set! executable-completions + (make-completion-set-for-executables (get-path-list)))))))) (define (paint-bar-1) (mvwaddstr (app-window-curses-win bar-1) 0 1 "SCSH-NUIT") @@ -828,7 +839,9 @@ (else (append (completions-for (command-completions) prefix) - (completions-for-executables executable-completions prefix))))) + (with-lock executable-completions-lock + (lambda () + (completions-for-executables executable-completions prefix))))))) (define (assemble-line-with-completion command arg arg-pos completion) (debug-message "assemble-line-with-completion "