Megatest

Diff
Login

Differences From Artifact [63dbb0e44d]:

To Artifact [4eb224d52b]:


225
226
227
228
229
230
231


232
233
234
235
236
237
238
239
240
241
242
243
244
245



246
247
248
249
250
251






























252
253
254
255
256
257
258
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250






251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287







+
+














+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







;; RA => sets the tabdat passed to the hashkey at commondat:tabdats hash table
;;
(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

  ;; maybe need sleep here?

  
  (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
					       '())))
	(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)
          ;; (debug:print 3 *default-log-port* "Running " updater)
	   (updater))
	 updaters))))
				       (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))
  (let* ((tnum          (or tab-num
			     (dboard:commondat-curr-tab-num commondat)))