@@ -227,10 +227,12 @@ (define (dboard:common-set-tabdat! commondat tabnum tabdat) (hash-table-set! (dboard:commondat-tabdats commondat) tabnum tabdat)) + +(define *updaters-running* #f) ;; gets and calls updater list based on curr-tab-num ;; (define (dboard:common-run-curr-updaters commondat #!key (tab-num #f)) ;; (sync-db-to-tmp (dboard:common-get-tabdat commondat tab-num: tab-num)) ;; no longer applies @@ -241,16 +243,43 @@ (if (dboard:common-get-tabdat commondat tab-num: tab-num) ;; only update if there is a tabdat (let* ((tnum (or tab-num (dboard:commondat-curr-tab-num commondat))) (updaters (hash-table-ref/default (dboard:commondat-updaters commondat) tnum '()))) - (debug:print 4 *default-log-port* "Found these updaters: " updaters " for tab-num: " tnum) - (for-each ;; perform the function calls for the complete updaters list - (lambda (updater) - ;; (debug:print 3 *default-log-port* "Running " updater) - (updater)) - updaters)))) + (if *updaters-running* + (debug:print 0 *default-log-port* "updaters still running.") + (let* ((th1 (make-thread (lambda () + (debug:print 4 *default-log-port* "Found these updaters: " updaters " for tab-num: " tnum) + (for-each ;; perform the function calls for the complete updaters list + (lambda (updater) + (let ((start-ms (current-milliseconds))) + (debug:print 0 *default-log-port* "Running updater for tnum "tnum", "updater) + (updater) + (debug:print 0 *default-log-port* "Running updater for tnum "tnum" took "(- (current-milliseconds) + start-ms)"ms") + )) + updaters)) + "updaters thread")) + (th2 (make-thread (lambda () + (let loop () + (case (thread-state th1) + ((terminated) + (debug:print 0 *default-log-port* "th1 terminated, all done for now.")) + ((running) + (thread-suspend! th1) + (thread-sleep! 0.1) + (loop)) + ((sleeping) + (thread-resume! th1) + (thread-sleep! 0.9) + (loop)) + (else + (loop)))))))) + (thread-start! th1) + (thread-sleep! 0.1) + (thread-start! th2) + (thread-join! th1)))))) ;; if tab-num passed in then use it, otherwise look in commondat at curr-tab-num ;; adds the updater passed in the updaters list at that hashkey ;; (define (dboard:commondat-add-updater commondat updater #!key (tab-num #f))