Changeset 39725 in project


Ignore:
Timestamp:
03/16/21 21:33:05 (3 months ago)
Author:
Kon Lovett
Message:

add unbuffered-cursor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/5/mailbox/trunk/inline-queue.scm

    r39724 r39725  
    197197  (error '%queue-limited-push-back-list! "unsupported" q ls) )
    198198
     199;index
    199200(define-inline (%make-queue-limited-cursor) (void))
    200201(define-inline (%queue-limited-cursor? c) #f)
     
    265266  (%queue-unbuffered-add! q (car ls)) )
    266267
    267 (define-inline (%make-queue-unbuffered-cursor) (void))
    268 (define-inline (%queue-unbuffered-cursor? c) #f)
     268(define-inline (%make-queue-unbuffered-cursor) (cons -1 (void)))
     269(define-inline (%queue-unbuffered-cursor? c) (pair c))
     270(define-inline (%queue-unbuffered-index c) (car c))
     271(define-inline (%queue-unbuffered-index-set! c v) (set-car! c v))
    269272
    270273(define-inline (%queue-unbuffered-cursor-winding? q c)
    271   (error '%queue-unbuffered-cursor-winding? "unsupported" q c) )
     274  (fx<= 0 (%queue-unbuffered-index c)) )
    272275
    273276(define-inline (%queue-unbuffered-cursor-unwound? q c)
    274   (error '%queue-unbuffered-cursor-unwound? "unsupported" q c) )
     277  (fx= 1 (%queue-unbuffered-index c)) )
    275278
    276279(define-inline (%queue-unbuffered-cursor-start! q c)
    277   (error '%queue-unbuffered-cursor-start! "unsupported" q c) )
     280  (%queue-unbuffered-index-set! c 0) )
    278281
    279282;#!eof | *
    280283(define-inline (%queue-unbuffered-cursor-next! q c)
    281   (error '%queue-unbuffered-cursor-next! "unsupported" q c) )
     284  (cond
     285    ((%queue-unbuffered-cursor-unwound? q c)  #!eof)
     286    ((not (%queue-unbuffered-maybe? q))       #!eof)
     287    (else
     288      (%queue-unbuffered-index-set! c 1)
     289      (%queue-unbuffered-value q) ) ) )
    282290
    283291(define-inline (%queue-unbuffered-cursor-continue! q c)
    284   (error '%queue-unbuffered-cursor-continue! "unsupported" q c) )
     292  (%queue-unbuffered-index-set! c 0) )
    285293
    286294(define-inline (%queue-unbuffered-cursor-rewind! q c)
    287   (error '%queue-unbuffered-cursor-rewind! "unsupported" q c) )
     295  (%queue-unbuffered-index-set! c -1) )
    288296
    289297(define-inline (%queue-unbuffered-cursor-extract! q c)
    290   (error '%queue-unbuffered-cursor-extract! "unsupported" q c) )
     298  ;unless 'mailbox-cursor-next' has been called don't remove
     299  (when (%queue-unbuffered-cursor-winding? q c)
     300    (%queue-unbuffered-maybe-set! q #f) ) )
    291301
    292302;; Queue Generic
Note: See TracChangeset for help on using the changeset viewer.