65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
;;======================================================================
;; We don't want to flush the queue if it was just flushed
(define *server:last-write-flush* (current-milliseconds))
;; Flush the queue every third of a second. Can we assume that setup-for-run
;; has already been done?
(define (server:write-queue-handler)
(if (setup-for-run)
(let ((db (open-db)))
(let loop ()
(let ((last-write-flush-time #f))
(mutex-lock! *incoming-mutex*)
(set! last-write-flush-time *server:last-write-flush*)
(mutex-unlock! *incoming-mutex*)
(if (> (- (current-milliseconds) last-write-flush-time) 10)
(begin
(mutex-lock! *db:process-queue-mutex*)
(db:process-cached-writes db)
(mutex-unlock! *db:process-queue-mutex*)
(thread-sleep! 0.005))))
(loop)))
(begin
(debug:print 0 "ERROR: failed to setup for Megatest in server:write-queue-handler")
(exit 1))))
;;======================================================================
;; S E R V E R U T I L I T I E S
;;======================================================================
;; Generate a unique signature for this server
(define (server:mk-signature)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
;;======================================================================
;; We don't want to flush the queue if it was just flushed
(define *server:last-write-flush* (current-milliseconds))
;; Flush the queue every third of a second. Can we assume that setup-for-run
;; has already been done?
;; (define (server:write-queue-handler)
;; (if (setup-for-run)
;; (let ((db (open-db)))
;; (let loop ()
;; (let ((last-write-flush-time #f))
;; (mutex-lock! *incoming-mutex*)
;; (set! last-write-flush-time *server:last-write-flush*)
;; (mutex-unlock! *incoming-mutex*)
;; (if (> (- (current-milliseconds) last-write-flush-time) 10)
;; (begin
;; (mutex-lock! *db:process-queue-mutex*)
;; (db:process-cached-writes db)
;; (mutex-unlock! *db:process-queue-mutex*)
;; (thread-sleep! 0.005))))
;; (loop)))
;; (begin
;; (debug:print 0 "ERROR: failed to setup for Megatest in server:write-queue-handler")
;; (exit 1))))
;;======================================================================
;; S E R V E R U T I L I T I E S
;;======================================================================
;; Generate a unique signature for this server
(define (server:mk-signature)
|