Megatest

Check-in [eba00b3478]
Login
Overview
Comment:couple more functions added for experimental dispatch
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.80-revolution-alt-dispatch
Files: files | file ages | folders
SHA1: eba00b3478e359c9105853f6f03a0e9329946370
User & Date: matt on 2024-01-28 15:47:10
Other Links: branch diff | manifest | tags
Context
2024-01-28
20:17
queue based handling WIP. Compiles and almost runs. check-in: 06c8fc61e9 user: matt tags: v1.80-revolution-alt-dispatch
15:47
couple more functions added for experimental dispatch check-in: eba00b3478 user: matt tags: v1.80-revolution-alt-dispatch
2024-01-27
18:57
Added bit more to api:tcp-dispatch stuff check-in: 3aeaa622a5 user: matt tags: v1.80-revolution
Changes

Modified api.scm from [637d41cdff] to [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