Megatest

Diff
Login

Differences From Artifact [637d41cdff]:

To Artifact [6d703cddc0]:


184
185
186
187
188
189
190


191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210

















211





212
213
214
215
216
217
218
	  (rmt:print-db-stats)
	  (set! *api:last-stats-print* (current-seconds))))
    (mutex-unlock! *api-print-db-stats-mutex*)
    (thread-sleep! 5)
    (loop)))

(define *api:queue-mutex* (make-mutex))


(define *api:in-queue* '())
(define *api:out-queue* '())

(define (api:start-queue-processor)
  ;; look for work in in-queue
  ;; process it
  ;; put result in out-queue
  ;; sleep 20ms
  
  #t)

(defstuct api:queue-item
  (proc #f)
  (cmd  #f)
  (params #f)
  (start-time (current-seconds))
  (end-time   #f)
  (id   #f))

(define (api:add-queue-item proc cmd params)

















  #f)






(define (api:tcp-dispatch-request-make-handler-new dbstruct) ;; cmd run-id params)

  ;;  put proc into in-queue
  ;;  poll out-queue for result evey 25ms
  ;;  time out with big message
  







>
>

|


















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>







184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
	  (rmt:print-db-stats)
	  (set! *api:last-stats-print* (current-seconds))))
    (mutex-unlock! *api-print-db-stats-mutex*)
    (thread-sleep! 5)
    (loop)))

(define *api:queue-mutex* (make-mutex))
(define *api:queue-id* 0)

(define *api:in-queue* '())
(define *api:results* (make-hash-table)) ;; id->queue-item

(define (api:start-queue-processor)
  ;; look for work in in-queue
  ;; process it
  ;; put result in out-queue
  ;; sleep 20ms
  
  #t)

(defstuct api:queue-item
  (proc #f)
  (cmd  #f)
  (params #f)
  (start-time (current-seconds))
  (end-time   #f)
  (id   #f))

(define (api:add-queue-item proc cmd params)
  (mutex-lock *api:queue-mutex*)
  (set! *api:queue-id* (+ *api:queue-id* 1))
  (set! *api:in-queue*
	(cons (make-api:queue-item
	       proc: proc
	       cmd: cmd
	       params: params
	       id: *api:queue-id*
	       )
	      *api:in-queue*))
  (let ((id *api:queue-id*))
    (mutex-unlock *apt:queue-mutex*)
    id)) ;; return id so calling proc can find the result in *api:results*

(define (api:get-queue-item)
  (mutex-lock *api:queue-mutex*)
  (let* ((res (if (null? *api:in-queue*)
		  #f
		  (let* ((revlst (reverse *api:in-queue*)))
		    (set! *api:in-queue* (reverse (cdr revlist)))
		    (car revlist)))))
    (mutex-unlock *api:queue-mutex*)
    res))

(define (api:tcp-dispatch-request-make-handler-new dbstruct) ;; cmd run-id params)

  ;;  put proc into in-queue
  ;;  poll out-queue for result evey 25ms
  ;;  time out with big message