mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-12 23:37:38 +02:00
Fix resize function
This commit is contained in:
parent
af2008cbcf
commit
364d2594b8
1 changed files with 15 additions and 10 deletions
|
@ -91,16 +91,21 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
(define (%queue-resize! q)
|
(define (%queue-resize! q)
|
||||||
(write "TODO: resize the queue")(newline)
|
;; (write "TODO: resize the queue")(newline)
|
||||||
; ;; TODO: assumes we already have the lock
|
;; TODO: assumes we already have the lock
|
||||||
; ;; TODO: error if size is larger than fixnum??
|
;; TODO: error if size is larger than fixnum??
|
||||||
; (let ((old-store (q:store q))
|
(let* ((old-start (q:start q))
|
||||||
; (new-store (make-vector (* (vector-length old-store) 2) #f)))
|
(old-end (q:end q))
|
||||||
; (q:set-size! q 0)
|
(old-store (q:store q))
|
||||||
; (let loop ((i (vector-length old-store)))
|
(new-store (make-vector (* (vector-length old-store) 2) #f)))
|
||||||
; (when (not (zero? i))
|
(q:set-start! q 0)
|
||||||
; (%queue-add! q (vector-ref
|
(q:set-end! q 0)
|
||||||
; (loop (- i 1)))))
|
(q:set-store! q new-store)
|
||||||
|
(let loop ((i 0)
|
||||||
|
(start old-start))
|
||||||
|
(when (not (= i (vector-length old-store)))
|
||||||
|
(%queue-add! q (vector-ref old-store start))
|
||||||
|
(loop (+ i 1) (inc start (vector-length old-store))))))
|
||||||
)
|
)
|
||||||
|
|
||||||
;- queue-remove! - remove item (when to block? would be nice if we can block until an item becomes available)
|
;- queue-remove! - remove item (when to block? would be nice if we can block until an item becomes available)
|
||||||
|
|
Loading…
Add table
Reference in a new issue