60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
(define *rmt-query-last-rest-time* 0) ;; last time there was at least a 1/2 second rest - giving other processes access to the db
;; NOTE: This query rest algorythm will not adapt to long query times. REDESIGN NEEDED. TODO. FIXME.
;;
(define (rmt:query-rest cmd rid params)
(let* ((now (current-milliseconds)))
(cond
((> (- now *rmt-query-last-call-time*) 500) ;; it's been a while since last query - no need to rest
(set! *rmt-query-last-rest-time* now)
(set! *rmt-query-last-call-time* now))
((> (- now *rmt-query-last-rest-time*) 5000) ;; no natural rests have happened
(debug:print 0 *default-log-port* "query rest needed. blocking for 1/2 second. cmd="cmd", run id="rid", params="params)
(thread-sleep! 0.5) ;; force a rest of a half second
(set! *rmt-query-last-rest-time* now)
(set! *rmt-query-last-call-time* now))
(else ;; sufficient rests have occurred, just record the last query time
(set! *rmt-query-last-call-time* now)))))
;; RA => e.g. usage (rmt:send-receive 'get-var #f (list varname))
;;
|
|
|
|
|
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
(define *rmt-query-last-rest-time* 0) ;; last time there was at least a 1/2 second rest - giving other processes access to the db
;; NOTE: This query rest algorythm will not adapt to long query times. REDESIGN NEEDED. TODO. FIXME.
;;
(define (rmt:query-rest cmd rid params)
(let* ((now (current-milliseconds)))
(cond
((> (- now *rmt-query-last-call-time*) 100) ;; it's been a while since last query - no need to rest
(set! *rmt-query-last-rest-time* now)
(set! *rmt-query-last-call-time* now))
((> (- now *rmt-query-last-rest-time*) 5000) ;; no natural rests have happened
(debug:print 0 *default-log-port* "query rest needed. blocking for 0.1 second. cmd="cmd", run id="rid", params="params)
(thread-sleep! 0.1) ;; force a rest of a half second
(set! *rmt-query-last-rest-time* now)
(set! *rmt-query-last-call-time* now))
(else ;; sufficient rests have occurred, just record the last query time
(set! *rmt-query-last-call-time* now)))))
;; RA => e.g. usage (rmt:send-receive 'get-var #f (list varname))
;;
|