342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
|
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
-
-
-
-
-
-
-
-
-
-
-
-
|
;; (boolean? res))
;; res
;; (list "ERROR, not string, list, number or boolean" 1 cmd params res)))))
(db:obj->string res transport: 'http)))
(define api:queue-mutex (make-mutex))
(defstruct api:queues
(enable #f)
(dbstruct #f) ;; must be initialized!
(mutex (make-mutex))
(readq '())
(writeq '())
(last-read (current-milliseconds))
(last-write (current-milliseconds))
(read-cvar (make-condition-variable "reads"))
(write-cvar (make-condition-variable "writes"))
)
;; api queued request handler
;;
;; qry-type: read write transaction
;;
(define (api:queued-request queues qry-type params proc)
;; add proc to read, write queue or if transaction do it immediately (for now, not sure but might need to process differently.)
(if *queues*
|