Changeset 39700 in project
- Timestamp:
- 03/14/21 16:55:30 (5 weeks ago)
- Location:
- release/5/mailbox/trunk
- Files:
-
- 1 added
- 2 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
release/5/mailbox/trunk/inline-queue.scm
r37684 r39700 13 13 ;the identifier needs to be defined by somebody 14 14 (define queue 'queue) 15 16 15 (define-record-type-variant queue (unsafe unchecked inline) 17 (% %make-queue hd tl)18 %queue?16 (%make-queue hd tl) 17 (%queue?) 19 18 (hd %queue-first-pair %queue-first-pair-set!) 20 19 (tl %queue-last-pair %queue-last-pair-set!) ) 21 20 22 (define-inline (%make- queue) (%%make-queue '() '()))21 (define-inline (%make-empty-queue) (%make-queue '() '())) 23 22 24 (define-inline (%queue-empty? q) ( $null? (%queue-first-pair q)))25 (define-inline (%queue-count q) ( $length (%queue-first-pair q)))23 (define-inline (%queue-empty? q) (null? (%queue-first-pair q))) 24 (define-inline (%queue-count q) (length (%queue-first-pair q))) 26 25 27 26 ;; Operations … … 30 29 31 30 (define-inline (%queue-add! q datum) 32 (let ((new-pair ( $cons datum '())))33 (if ( $null? (%queue-first-pair q))31 (let ((new-pair (cons datum '()))) 32 (if (null? (%queue-first-pair q)) 34 33 (%queue-first-pair-set! q new-pair) 35 ( $set-cdr! (%queue-last-pair q) new-pair) )34 (set-cdr! (%queue-last-pair q) new-pair) ) 36 35 (%queue-last-pair-set! q new-pair) ) ) 37 36 38 37 (define-inline (%queue-remove! q) 39 38 (let* ((first-pair (%queue-first-pair q)) 40 (next-pair ( $cdr first-pair)))39 (next-pair (cdr first-pair))) 41 40 (%queue-first-pair-set! q next-pair) 42 (when ( $null? next-pair) (%queue-last-pair-empty! q) )43 ( $car first-pair) ) )41 (when (null? next-pair) (%queue-last-pair-empty! q) ) 42 (car first-pair) ) ) 44 43 45 44 (define-inline (%queue-push-back! q item) 46 (let ((newlist ( $cons item (%queue-first-pair q))))45 (let ((newlist (cons item (%queue-first-pair q)))) 47 46 (%queue-first-pair-set! q newlist) 48 (when ( $null? (%queue-last-pair q)) (%queue-last-pair-set! q newlist) ) ) )47 (when (null? (%queue-last-pair q)) (%queue-last-pair-set! q newlist) ) ) ) 49 48 50 49 (define-inline (%queue-push-back-list! q itemlist) 51 (let ((newlist ( $append! ($list-copy itemlist) (%queue-first-pair q))))50 (let ((newlist (append! (list-copy itemlist) (%queue-first-pair q)))) 52 51 (%queue-first-pair-set! q newlist) 53 (if ( $null? newlist)52 (if (null? newlist) 54 53 (%queue-last-pair-empty! q) 55 (%queue-last-pair-set! q ( $last-pair newlist) ) ) ) )54 (%queue-last-pair-set! q (last-pair newlist) ) ) ) ) 56 55 57 56 (define-inline (%queue-extract-pair! q targ-pair) … … 65 64 (warning "cannot find queue pair to extract; simultaneous operations?")) 66 65 ;found? 67 (( $eq? this-pair targ-pair)66 ((eq? this-pair targ-pair) 68 67 ;so cut out the pair 69 (let ((next-pair ( $cdr this-pair)))68 (let ((next-pair (cdr this-pair))) 70 69 ;at the head of the list, or in the body? 71 (if ( $null? prev-pair)70 (if (null? prev-pair) 72 71 (%queue-first-pair-set! q next-pair) 73 ( $set-cdr! prev-pair next-pair) )72 (set-cdr! prev-pair next-pair) ) 74 73 ;when the cut pair is the last item update the last pair ref. 75 (when ( $eq? this-pair (%queue-last-pair q))74 (when (eq? this-pair (%queue-last-pair q)) 76 75 (%queue-last-pair-set! q prev-pair)) ) ) 77 76 ;not found 78 77 (else 79 (scanning ( $cdr this-pair) this-pair) ) ) ) )78 (scanning (cdr this-pair) this-pair) ) ) ) ) -
release/5/mailbox/trunk/inline-type-checks.scm
r36012 r39700 19 19 20 20 (unsafe 21 21 22 22 (define-syntax define-inline-check-type 23 23 (er-macro-transformer … … 56 56 (typstr (symbol->string typ)) 57 57 (pred (if (not (null? (cddr frm))) (caddr frm) 58 (string->symbol (string-append "%" typstr "?"))))58 (string->symbol (string-append #;"%" typstr "?")))) 59 59 (nam (string->symbol (string-append "%check-" typstr))) 60 60 (errnam (string->symbol (string-append "error-" typstr))) ) -
release/5/mailbox/trunk/mailbox.egg
r39006 r39700 14 14 (types-file) 15 15 (csc-options 16 "-feature" "unsafe-operations"17 16 ;"-feature" "sleep-primordial-thread" 18 17 "-O3" "-d1" "-strict-types" "-no-procedure-checks" "-no-bound-checks") ) ) ) -
release/5/mailbox/trunk/mailbox.scm
r39012 r39700 6 6 7 7 ;; Issues 8 ;;9 ;; - When compile-time feature `unsafe-operations' inlined & primitive routines used.10 8 ;; 11 9 ;; - Has explicit "unspecified" returns in some cases to avoid leaks of internal … … 61 59 mailbox-cursor-extract-and-rewind!) 62 60 63 (import scheme )64 (import (chicken base))65 (import (chicken syntax))66 (import (chicken condition))67 (import (chicken type))68 (import (only (chicken port) with-output-to-port))69 (import (only (chicken format) printf))70 (import (only (chicken string) ->string))71 (import (only (srfi 1) append! delete! list-copy last-pair))72 (import(only (srfi 18)73 time?74 current-thread75 thread-signal! thread-sleep!76 thread-suspend! thread-resume!))77 (importrecord-variants)61 (import scheme 62 (chicken base) 63 (chicken syntax) 64 (chicken condition) 65 (chicken type) 66 (only (chicken port) with-output-to-port) 67 (only (chicken format) printf) 68 (only (chicken string) ->string) 69 (only (srfi 1) append! delete! list-copy last-pair) 70 (only (srfi 18) 71 time? 72 current-thread 73 thread-signal! thread-sleep! 74 thread-suspend! thread-resume!) 75 record-variants) 78 76 79 77 ;;; Support 80 78 81 ;; 82 83 (define-inline (->boolean obj) (and obj #t)) 84 85 ;;miscmacros, Felix Winkelmann 79 ;;miscmacros 86 80 87 81 ;; evaluates body with an explicit exit continuation … … 93 87 (lambda (k) e0 e1 ...))))) 94 88 95 ;;96 97 (define-type srfi-18-time (struct time))98 99 (define-type mailbox (struct mailbox))100 101 (define-type mailbox-cursor (struct mailbox-cursor))102 103 (define-type time-number (or fixnum float))104 105 (define-type timeout (or time-number srfi-18-time))106 107 (define-type unique-object (vector-of symbol))108 109 (: mailbox-timeout-condition? (* -> boolean : condition))110 (: make-mailbox (#!optional * -> mailbox))111 (: mailbox? (* -> boolean : mailbox))112 (: mailbox-name (mailbox --> *))113 (: mailbox-empty? (mailbox -> boolean))114 (: mailbox-count (mailbox -> fixnum))115 (: mailbox-waiting? (mailbox -> boolean))116 (: mailbox-waiters (mailbox -> list))117 (: mailbox-send! (mailbox * -> void))118 (: mailbox-wait! (mailbox #!optional timeout -> void))119 (: mailbox-receive! (mailbox #!optional timeout * -> *))120 (: mailbox-push-back! (mailbox * -> void))121 (: mailbox-push-back-list! (mailbox list -> void))122 (: make-mailbox-cursor (mailbox -> mailbox-cursor))123 (: mailbox-cursor? (* -> boolean : mailbox-cursor))124 (: mailbox-cursor-mailbox (mailbox-cursor --> mailbox))125 (: mailbox-cursor-rewound? (mailbox-cursor -> boolean))126 (: mailbox-cursor-unwound? (mailbox-cursor -> boolean))127 (: mailbox-cursor-rewind (mailbox-cursor -> void))128 (: mailbox-cursor-next (mailbox-cursor #!optional timeout * -> *))129 (: mailbox-cursor-extract-and-rewind! (mailbox-cursor -> void))130 131 89 ;;(only type-errors define-error-type) 132 90 … … 148 106 (##sys#signal-hook #:type-error loc obj (make-error-type-message 'list argnam) obj) ) 149 107 150 ;;; Primitives 151 152 (include "chicken-primitive-object-inlines") 153 (include "chicken-thread-object-inlines") 154 (include "inline-type-checks") 155 (include "inline-queue") 156 157 (cond-expand 158 (unsafe-operations 159 (define-syntax $eq? (syntax-rules () ((_ ?arg0 ...) (%eq? ?arg0 ...)))) 160 (define-syntax $null? (syntax-rules () ((_ ?arg0 ...) (%null? ?arg0 ...)))) 161 (define-syntax $list? (syntax-rules () ((_ ?arg0 ...) (%list? ?arg0 ...)))) 162 (define-syntax $length (syntax-rules () ((_ ?arg0 ...) (%length ?arg0 ...)))) 163 (define-syntax $append! (syntax-rules () ((_ ?arg0 ...) (%append! ?arg0 ...)))) 164 (define-syntax $delq! (syntax-rules () ((_ ?arg0 ...) (%delq! ?arg0 ...)))) 165 (define-syntax $cons (syntax-rules () ((_ ?arg0 ...) (%cons ?arg0 ...)))) 166 (define-syntax $car (syntax-rules () ((_ ?arg0 ...) (%car ?arg0 ...)))) 167 (define-syntax $cdr (syntax-rules () ((_ ?arg0 ...) (%cdr ?arg0 ...)))) 168 (define-syntax $set-car! (syntax-rules () ((_ ?arg0 ...) (%set-car! ?arg0 ...)))) 169 (define-syntax $set-cdr! (syntax-rules () ((_ ?arg0 ...) (%set-cdr! ?arg0 ...)))) 170 (define-syntax $list-copy (syntax-rules () ((_ ?arg0 ...) (%list-copy ?arg0 ...)))) 171 (define-syntax $last-pair (syntax-rules () ((_ ?arg0 ...) (%last-pair ?arg0 ...)))) 172 (define-syntax $current-thread (syntax-rules () ((_ ?arg0 ...) (%current-thread ?arg0 ...)))) 173 (define-syntax $thread-blocked? (syntax-rules () ((_ ?arg0 ...) (%thread-blocked? ?arg0 ...)))) 174 (define-syntax $thread-blocked-for-timeout? (syntax-rules () ((_ ?arg0 ...) (%thread-blocked-for-timeout? ?arg0 ...)))) ) 175 (else 176 (define-syntax $eq? (syntax-rules () ((_ ?arg0 ...) (eq? ?arg0 ...)))) 177 (define-syntax $null? (syntax-rules () ((_ ?arg0 ...) (null? ?arg0 ...)))) 178 (define-syntax $list? (syntax-rules () ((_ ?arg0 ...) (list? ?arg0 ...)))) 179 (define-syntax $length (syntax-rules () ((_ ?arg0 ...) (length ?arg0 ...)))) 180 (define-syntax $append! (syntax-rules () ((_ ?arg0 ...) (append! ?arg0 ...)))) 181 (define-syntax $delq! (syntax-rules () ((_ ?arg0 ...) (delete! ?arg0 ...)))) 182 (define-syntax $cons (syntax-rules () ((_ ?arg0 ...) (cons ?arg0 ...)))) 183 (define-syntax $car (syntax-rules () ((_ ?arg0 ...) (car ?arg0 ...)))) 184 (define-syntax $cdr (syntax-rules () ((_ ?arg0 ...) (cdr ?arg0 ...)))) 185 (define-syntax $set-car! (syntax-rules () ((_ ?arg0 ...) (set-car! ?arg0 ...)))) 186 (define-syntax $set-cdr! (syntax-rules () ((_ ?arg0 ...) (set-cdr! ?arg0 ...)))) 187 (define-syntax $list-copy (syntax-rules () ((_ ?arg0 ...) (list-copy ?arg0 ...)))) 188 (define-syntax $last-pair (syntax-rules () ((_ ?arg0 ...) (last-pair ?arg0 ...)))) 189 (define-syntax $current-thread (syntax-rules () ((_ ?arg0 ...) (current-thread ?arg0 ...)))) 190 (define ($thread-blocked? th) (eq? 'blocked (##sys#slot th 3))) 191 (define ($thread-blocked-for-timeout? th) (and (##sys#slot th 4) (not (##sys#slot th 11)))) ) ) 192 193 ;;; Mailbox Support 194 195 ;; Mailbox 108 (include-relative "inline-type-checks") 109 110 ;; 111 112 (define-inline (%delq! x ls0) 113 ;(assert (proper-list? ls0)) 114 (let find-elm ((ls ls0) (ppr #f)) 115 (cond ((null? ls) 116 ls0 ) 117 ((eq? x (car ls)) 118 (cond (ppr 119 (set-cdr! ppr (cdr ls)) 120 ls0 ) 121 (else 122 (cdr ls) ) ) ) 123 (else 124 (find-elm (cdr ls) ls) ) ) ) ) 125 126 (define-inline (%thread-blocked? th) (eq? 'blocked (##sys#slot th 3))) 127 (define-inline (%thread-blocked-for-timeout? th) (and (##sys#slot th 4) (not (##sys#slot th 11)))) 128 129 (define-inline (%->boolean obj) (and obj #t)) 130 131 (define-inline (%make-unique-object #!optional (id 'unique)) (vector id)) 132 133 ;; Time Support 134 135 (define-inline (%time-number? obj) 136 (or (fixnum? obj) (flonum? obj)) ) 137 138 (define-inline (%timeout? obj) 139 (or (%time-number? obj) (time? obj)) ) 140 141 (define (error-timeout loc obj #!optional argnam) 142 (##sys#signal-hook #:type-error loc (make-error-type-message 'timeout argnam) obj) ) 143 144 (define (timeout? obj) (%timeout? obj)) 145 146 (define-inline-check-type timeout) 147 148 ;; Queue Support 149 150 (include-relative "inline-queue") 151 152 ;;; Typoes 153 154 (define-type srfi-18-time (struct time)) 155 (define-type mailbox (struct mailbox)) 156 (define-type mailbox-cursor (struct mailbox-cursor)) 157 (define-type time-number (or fixnum float)) 158 (define-type timeout (or time-number srfi-18-time)) 159 (define-type unique-object (vector-of symbol)) 160 161 (: mailbox-timeout-condition? (* -> boolean : condition)) 162 (: make-mailbox (#!optional * -> mailbox)) 163 (: mailbox? (* -> boolean : mailbox)) 164 (: mailbox-name (mailbox --> *)) 165 (: mailbox-empty? (mailbox -> boolean)) 166 (: mailbox-count (mailbox -> fixnum)) 167 (: mailbox-waiting? (mailbox -> boolean)) 168 (: mailbox-waiters (mailbox -> list)) 169 (: mailbox-send! (mailbox * -> void)) 170 (: mailbox-wait! (mailbox #!optional timeout -> void)) 171 (: mailbox-receive! (mailbox #!optional timeout * -> *)) 172 (: mailbox-push-back! (mailbox * -> void)) 173 (: mailbox-push-back-list! (mailbox list -> void)) 174 (: make-mailbox-cursor (mailbox -> mailbox-cursor)) 175 (: mailbox-cursor? (* -> boolean : mailbox-cursor)) 176 (: mailbox-cursor-mailbox (mailbox-cursor --> mailbox)) 177 (: mailbox-cursor-rewound? (mailbox-cursor -> boolean)) 178 (: mailbox-cursor-unwound? (mailbox-cursor -> boolean)) 179 (: mailbox-cursor-rewind (mailbox-cursor -> void)) 180 (: mailbox-cursor-next (mailbox-cursor #!optional timeout * -> *)) 181 (: mailbox-cursor-extract-and-rewind! (mailbox-cursor -> void)) 182 183 ;;; Mailbox 196 184 197 185 ;the identifier needs to be defined by somebody 198 186 (define mailbox 'mailbox) 199 200 187 (define-record-type-variant mailbox (unsafe unchecked inline) 201 188 (%raw-make-mailbox nm qu wt) 202 %mailbox?189 (%mailbox?) 203 190 (nm %mailbox-name) 204 191 (qu %mailbox-queue) … … 206 193 207 194 (define-inline (%make-mailbox nm) 208 (%raw-make-mailbox nm (%make- queue) '()) )195 (%raw-make-mailbox nm (%make-empty-queue) '()) ) 209 196 210 197 (define (error-mailbox loc obj #!optional argnam) … … 242 229 243 230 (define-inline (%mailbox-waiters-empty? mb) 244 ( $null? (%mailbox-waiters mb)) )231 (null? (%mailbox-waiters mb)) ) 245 232 246 233 (define-inline (%mailbox-waiters-count mb) 247 ( $length (%mailbox-waiters mb)) )234 (length (%mailbox-waiters mb)) ) 248 235 249 236 (define-inline (%mailbox-waiters-add! mb th) 250 (%mailbox-waiters-set! mb ( $append! (%mailbox-waiters mb) ($cons th '()))) )237 (%mailbox-waiters-set! mb (append! (%mailbox-waiters mb) (cons th '()))) ) 251 238 252 239 (define-inline (%mailbox-waiters-delete! mb th) 253 (%mailbox-waiters-set! mb ( $delq! th (%mailbox-waiters mb))) )240 (%mailbox-waiters-set! mb (%delq! th (%mailbox-waiters mb))) ) 254 241 255 242 (define-inline (%mailbox-waiters-pop! mb) 256 243 (let ((ts (%mailbox-waiters mb))) 257 (%mailbox-waiters-set! mb ( $cdr ts))258 ( $car ts) ) )244 (%mailbox-waiters-set! mb (cdr ts)) 245 (car ts) ) ) 259 246 260 247 ;;; Mailbox Cursor Support … … 262 249 ;the identifier needs to be defined by somebody 263 250 (define mailbox-cursor 'mailbox-cursor) 264 265 251 (define-record-type-variant mailbox-cursor (unsafe unchecked inline) 266 252 (%raw-make-mailbox-cursor np pp mb) 267 %mailbox-cursor?253 (%mailbox-cursor?) 268 254 (np %mailbox-cursor-next-pair %mailbox-cursor-next-pair-set!) 269 255 (pp %mailbox-cursor-prev-pair %mailbox-cursor-prev-pair-set!) … … 279 265 280 266 (define-inline (%mailbox-cursor-winding? mbc) 281 ( ->boolean (%mailbox-cursor-prev-pair mbc)) )267 (%->boolean (%mailbox-cursor-prev-pair mbc)) ) 282 268 283 269 (define-inline (%mailbox-cursor-next-pair-empty! mbc) … … 295 281 (and-let* ((prev-pair (%mailbox-cursor-prev-pair mbc))) 296 282 (%queue-extract-pair! (%mailbox-queue (%mailbox-cursor-mailbox mbc)) prev-pair) ) ) 297 298 ;; Time Support299 300 (define-inline (%time-number? obj)301 (or (fixnum? obj) (flonum? obj)) )302 303 (define-inline (%timeout? obj)304 (or (%time-number? obj) (time? obj)) )305 306 (define (error-timeout loc obj #!optional argnam)307 (##sys#signal-hook #:type-error loc (make-error-type-message 'timeout argnam) obj) )308 309 (define-inline-check-type timeout)310 283 311 284 ;;; … … 321 294 322 295 (define-inline (optional-timeout-value x #!optional (def (void))) 323 (if ( $eq? x NO-TOVAL-TAG) def x) )296 (if (eq? x NO-TOVAL-TAG) def x) ) 324 297 325 298 (define (make-mailbox-timeout-condition loc mb timout timout-value) … … 344 317 (and-let* ((th (%mailbox-waiters-pop!? mb))) 345 318 ;ready the thread based on wait mode 346 (if (not ( $thread-blocked? th))319 (if (not (%thread-blocked? th)) 347 320 ;then restart 348 321 (thread-resume! th) 349 322 ;else wake early if sleeping 350 323 ;all others dropped on the floor 351 (when ( $thread-blocked-for-timeout? th)324 (when (%thread-blocked-for-timeout? th) 352 325 ;ready the thread 353 326 (##sys#thread-unblock! th) … … 365 338 (with-exception-handler 366 339 (lambda (exp) 367 (if ( $eq? unblocked-tag exp)340 (if (eq? unblocked-tag exp) 368 341 (return #f) 369 342 ;propagate any "real" exception. … … 379 352 ;no available message due to timeout 380 353 (define (timeout-exit!) 381 (if (not ( $eq? timout-value NO-TOVAL-TAG))354 (if (not (eq? timout-value NO-TOVAL-TAG)) 382 355 timout-value 383 356 (begin 384 357 (thread-signal! 385 ( $current-thread)358 (current-thread) 386 359 (make-mailbox-timeout-condition loc mb timout timout-value)) 387 360 SEQ-FAIL-TAG ) ) ) 388 361 ; 389 362 ;push current thread on mailbox waiting queue 390 (%mailbox-waiters-add! mb ( $current-thread))363 (%mailbox-waiters-add! mb (current-thread)) 391 364 ;waiting action 392 365 (cond … … 400 373 ;timed-out, so no message 401 374 ;remove from wait queue 402 (%mailbox-waiters-delete! mb ( $current-thread))375 (%mailbox-waiters-delete! mb (current-thread)) 403 376 ;indicate no available message 404 377 (timeout-exit!) ) … … 408 381 (else 409 382 ; 410 (if (eq? ( $current-thread) ##sys#primordial-thread)383 (if (eq? (current-thread) ##sys#primordial-thread) 411 384 (begin 412 (%mailbox-waiters-delete! mb ( $current-thread))385 (%mailbox-waiters-delete! mb (current-thread)) 413 386 (warning "mailbox attempt to sleep primordial-thread" mb) 414 387 (timeout-exit!) ) … … 417 390 ;timed-out, so no message 418 391 ;remove from wait queue 419 (%mailbox-waiters-delete! mb ( $current-thread))392 (%mailbox-waiters-delete! mb (current-thread)) 420 393 ;indicate no available message 421 394 (timeout-exit!) ) … … 425 398 ;no timeout so suspend until something delivered 426 399 (else 427 (thread-suspend! ( $current-thread))400 (thread-suspend! (current-thread)) 428 401 ;we're resumed 429 402 UNBLOCKED-TAG ) ) ) … … 441 414 (let ((res (wait-mailbox-thread! ?loc _mb _to _tv))) 442 415 ;when a thread ready then check mailbox again, could be empty. 443 (if ( $eq? UNBLOCKED-TAG res)416 (if (eq? UNBLOCKED-TAG res) 444 417 (waiting) 445 418 ;else some sort of problem … … 483 456 484 457 (define (mailbox-waiting? mb) 485 (not ( $null? (%mailbox-waiters (%check-mailbox 'mailbox-waiting? mb)))) )458 (not (null? (%mailbox-waiters (%check-mailbox 'mailbox-waiting? mb)))) ) 486 459 487 460 (define (mailbox-waiters mb) 488 ( $list-copy (%mailbox-waiters (%check-mailbox 'mailbox-waiters mb))) )461 (list-copy (%mailbox-waiters (%check-mailbox 'mailbox-waiters mb))) ) 489 462 490 463 ;; Mailbox Operations … … 515 488 (%mailbox-queue-push-back-list! 516 489 (%check-mailbox 'mailbox-send! mb) 517 (%check-list ls 'mailbox-send!))490 (%check-list 'mailbox-push-back-list! ls 'mailbox-send!)) 518 491 (ready-mailbox-thread! mb) ) 519 492 520 493 ;; Read/Print Syntax 521 494 522 (define -record-printer (mailboxmb out)495 (define (mailbox-print mb out) 523 496 (with-output-to-port out 524 497 (lambda () … … 547 520 548 521 (define (mailbox-cursor-unwound? mbc) 549 ( $null? (%mailbox-cursor-next-pair (%check-mailbox-cursor 'mailbox-cursor-unwound? mbc))) )522 (null? (%mailbox-cursor-next-pair (%check-mailbox-cursor 'mailbox-cursor-unwound? mbc))) ) 550 523 551 524 ;; Mailbox Cursor Operations … … 564 537 (let ((curr-pair (%mailbox-cursor-next-pair mbc))) 565 538 ;anything next? 566 (if (not ( $null? curr-pair))539 (if (not (null? curr-pair)) 567 540 ;then peek into the queue for the next item 568 (let ((item ( $car curr-pair)))541 (let ((item (car curr-pair))) 569 542 (%mailbox-cursor-prev-pair-set! mbc curr-pair) 570 (%mailbox-cursor-next-pair-set! mbc ( $cdr curr-pair))543 (%mailbox-cursor-next-pair-set! mbc (cdr curr-pair)) 571 544 item ) 572 545 ;else wait for something in the mailbox … … 574 547 (cond 575 548 ;continue scanning? 576 (( $eq? UNBLOCKED-TAG res)549 ((eq? UNBLOCKED-TAG res) 577 550 (%mailbox-cursor-next-pair-set! mbc (%mailbox-queue-last-pair mb)) 578 551 (scanning) ) … … 587 560 ;; Read/Print Syntax 588 561 589 (define -record-printer (mailbox-cursormbc out)562 (define (mailbox-cursor-print mbc out) 590 563 (with-output-to-port out 591 564 (lambda () … … 594 567 (if (%mailbox-cursor-winding? mbc) "winding" "rewound")) ) ) ) 595 568 569 ;;; 570 571 (set! (record-printer mailbox) mailbox-print) 572 (set! (record-printer mailbox-cursor) mailbox-cursor-print) 573 596 574 ) ;module mailbox -
release/5/mailbox/trunk/tests/mailbox-cursor-test.scm
r36192 r39700 27 27 28 28 (define (thread-labeled-print . args) 29 (apply print (current-thread-name) " - " args) 30 #; ;only 2 threads! 29 31 (critical-section (apply print (current-thread-name) " - " args) ) ) 30 32 -
release/5/mailbox/trunk/tests/mailbox-primordial-test.scm
r38524 r39700 22 22 23 23 (assert (eq? ##sys#primordial-thread (current-thread))) 24 (define *primordial-thread* ##sys#primordial-thread)25 26 ;;27 24 28 25 (define (test-thread) 29 26 (thread-sleep! 1) 30 (thread-signal! *primordial-thread*'example) )27 (thread-signal! ##sys#primordial-thread 'example) ) 31 28 32 29 (define test-thread-1 (thread-start! test-thread)) 33 34 ;;35 30 36 31 ;#; ;this hangs forever and eats all my cycles (with timeout) -
release/5/mailbox/trunk/tests/reader-writer-test.scm
r36192 r39700 29 29 30 30 (define (thread-labeled-print . args) 31 (apply print (current-thread-name) " - " args) 32 #; ;only 2 threads! 31 33 (critical-section (apply print (current-thread-name) " - " args) ) ) 32 34 -
release/5/mailbox/trunk/tests/run.scm
r38524 r39700 3 3 (import scheme) 4 4 5 ;; ;Create Egg Const5 ;; Create Egg Const 6 6 7 ( define EGG-NAME "mailbox")7 (include-relative "run-ident") 8 8 9 9 ;chicken-install invokes as "<csi> -s run.scm <eggnam> <eggdir>" … … 18 18 19 19 (define *args* (argv)) 20 (define *current-directory* (cond-expand (unix "./") (else #f))) 21 ;no -disable-interrupts or -no-lambda-info 22 (define *csc-init-options* '(-inline-global -local -inline -specialize 23 -optimize-leaf-routines -clustering -lfa2 -no-trace -unsafe -strict-types)) 24 (define *test-files-rx* (irregex '(: (+ graph) #\- "test" #\. "scm"))) 20 25 21 (define (egg-name args #!optional (def EGG-NAME)) 26 (define (remq obj ls) 27 (let loop ((curr ls) (prev '())) 28 (cond 29 ((null? curr) 30 ls ) 31 ((eq? obj (car curr)) 32 (if (null? prev) 33 (cdr ls) 34 (begin 35 (set-cdr! prev (cdr curr)) 36 ls ) ) ) 37 (else 38 (loop (cdr curr) curr) ) ) ) ) 39 40 (define (remqs os ls) 41 (let loop ((ls ls) (os os)) 42 (cond 43 ((null? os) 44 ls ) 45 (else 46 (loop (remq (car os) ls) (cdr os)) ) ) ) ) 47 48 (define (egg-name #!optional (args *args*) (def EGG-NAME)) 22 49 (cond 23 50 ((<= 4 (length *args*)) (cadddr *args*) ) … … 26 53 (error 'run "cannot determine egg-name") ) ) ) 27 54 28 (define *current-directory* (cond-expand (unix "./") (else #f)))29 (define *egg* (egg-name *args*))55 (define (as-csc-options ls) 56 (apply string-append (intersperse (map symbol->string ls) " ")) ) 30 57 31 ;no -disable-interrupts or -no-lambda-info 32 (define *csc-options* "-inline-global -local -inline \ 33 -specialize -optimize-leaf-routines -clustering -lfa2 \ 34 -no-trace -unsafe \ 35 -strict-types") 58 (define (csc-options) 59 (as-csc-options (remqs *csc-remv-options* *csc-init-options*)) ) 36 60 37 (define *test-files-rx* (irregex '(: (+ graph) #\- "test" #\. "scm")))38 61 (define (test-filename name) (string-append name "-test")) 62 39 63 (define (test-files) (find-files "." #:test *test-files-rx* #:limit 1)) 40 64 … … 43 67 name 44 68 (make-pathname *current-directory* (test-filename name) "scm") ) ) 69 70 ;; 45 71 46 72 (define (run-test-evaluated source) … … 54 80 (system (pathname-replace-directory (pathname-strip-extension source) *current-directory*)) ) 55 81 56 ;;; 57 58 (define (run-test #!optional (name *egg*) (csc-options *csc-options*)) 82 (define (run-test #!optional (name (egg-name)) (csc-options (csc-options))) 59 83 (let ( 60 84 (source (ensure-test-source-name name)) ) … … 65 89 (run-test-compiled source csc-options) ) ) 66 90 67 (define (run-tests #!optional (tests (test-files)) (csc-options *csc-options*))91 (define (run-tests #!optional (tests (test-files)) (csc-options (csc-options))) 68 92 (for-each (cut run-test <> csc-options) tests) ) 69 93 70 ;; ;Do Test94 ;; Do Test 71 95 72 96 (run-tests)
Note: See TracChangeset
for help on using the changeset viewer.