Changeset 39006 in project


Ignore:
Timestamp:
09/05/20 23:05:10 (3 weeks ago)
Author:
Kon Lovett
Message:

type is interface

Location:
release/5/mailbox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/5/mailbox/tags/3.3.6/mailbox.scm

    r38485 r39006  
    7979;;; Support
    8080
     81;;
     82
     83(define-inline (->boolean obj) (and obj #t))
     84
    8185;;miscmacros, Felix Winkelmann
    8286
     
    9397(define-type srfi-18-time (struct time))
    9498
    95 ;;
    96 
    97 (define-inline (->boolean obj) (and obj #t))
     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))
    98130
    99131;;(only type-errors define-error-type)
    100 
    101 ;;
    102132
    103133(define (make-bad-argument-message #!optional argnam)
     
    114144    " type - not "
    115145    (make-type-name-message typnam)) )
    116 
    117 ;;
    118146
    119147(define (error-list loc obj #!optional argnam)
     
    167195;; Mailbox
    168196
    169 (define-type mailbox (struct mailbox))
    170 
    171197;the identifier needs to be defined by somebody
    172198(define mailbox 'mailbox)
     
    234260;;; Mailbox Cursor Support
    235261
    236 (define-type mailbox-cursor (struct mailbox-cursor))
    237 
    238262;the identifier needs to be defined by somebody
    239263(define mailbox-cursor 'mailbox-cursor)
     
    274298;; Time Support
    275299
    276 (define-type time-number (or fixnum float))
    277 
    278300(define-inline (%time-number? obj)
    279301  (or (fixnum? obj) (flonum? obj)) )
    280302
    281 (define-type timeout (or time-number srfi-18-time))
    282 
    283303(define-inline (%timeout? obj)
    284304  (or (%time-number? obj) (time? obj)) )
     
    290310
    291311;;;
    292 
    293 (define-type unique-object (vector-of symbol))
    294312
    295313;Unique objects used as tags
     
    439457;; Mailbox Exceptions
    440458
    441 (: mailbox-timeout-condition? (* -> boolean : condition))
    442 ;
    443459(define (mailbox-timeout-condition? obj)
    444460  (and
     
    449465;; Mailbox Constructor
    450466
    451 (: make-mailbox (#!optional * -> mailbox))
    452 ;
    453467(define (make-mailbox #!optional (nm (gensym 'mailbox)))
    454468  (%make-mailbox nm) )
    455469
    456 (: mailbox? (* -> boolean : mailbox))
    457 ;
    458470(define (mailbox? obj)
    459471  (%mailbox? obj) )
     
    461473;; Mailbox Properties
    462474
    463 (: mailbox-name (mailbox --> *))
    464 ;
    465475(define (mailbox-name mb)
    466476  (%mailbox-name (%check-mailbox 'mailbox-name mb)) )
    467477
    468 (: mailbox-empty? (mailbox -> boolean))
    469 ;
    470478(define (mailbox-empty? mb)
    471479  (%mailbox-queue-empty? (%check-mailbox 'mailbox-empty? mb)) )
    472480
    473 (: mailbox-count (mailbox -> fixnum))
    474 ;
    475481(define (mailbox-count mb)
    476482  (%mailbox-queue-count (%check-mailbox 'mailbox-count mb)) )
    477483
    478 (: mailbox-waiting? (mailbox -> boolean))
    479 ;
    480484(define (mailbox-waiting? mb)
    481485  (not ($null? (%mailbox-waiters (%check-mailbox 'mailbox-waiting? mb)))) )
    482486
    483 (: mailbox-waiters (mailbox -> list))
    484 ;
    485487(define (mailbox-waiters mb)
    486488  ($list-copy (%mailbox-waiters (%check-mailbox 'mailbox-waiters mb))) )
     
    488490;; Mailbox Operations
    489491
    490 (: mailbox-send! (mailbox * -> void))
    491 ;
    492492(define (mailbox-send! mb x)
    493493  (%mailbox-queue-add! (%check-mailbox 'mailbox-send! mb) x)
    494494  (ready-mailbox-thread! mb) )
    495495
    496 (: mailbox-wait! (mailbox #!optional timeout -> void))
    497 ;
    498496(define (mailbox-wait! mb #!optional timout)
    499497  (when timout (%check-timeout 'mailbox-wait! timout))
     
    503501    (void) ) )
    504502
    505 (: mailbox-receive! (mailbox #!optional timeout * -> *))
    506 ;
    507503(define (mailbox-receive! mb #!optional timout (timout-value NO-TOVAL-TAG))
    508504  (when timout (%check-timeout 'mailbox-receive! timout))
     
    512508    (%mailbox-queue-remove! mb) ) )
    513509
    514 (: mailbox-push-back! (mailbox * -> void))
    515 ;
    516510(define (mailbox-push-back! mb x)
    517511  (%mailbox-queue-push-back! (%check-mailbox 'mailbox-send! mb) x)
    518512  (ready-mailbox-thread! mb) )
    519513
    520 (: mailbox-push-back-list! (mailbox list -> void))
    521 ;
    522514(define (mailbox-push-back-list! mb ls)
    523515  (%mailbox-queue-push-back-list!
     
    540532;; Mailbox Cursor Constructor
    541533
    542 (: make-mailbox-cursor (mailbox -> mailbox-cursor))
    543 ;
    544534(define (make-mailbox-cursor mb)
    545535  (%make-mailbox-cursor (%check-mailbox 'make-mailbox-cursor mb)) )
     
    547537;; Mailbox Cursor Properties
    548538
    549 (: mailbox-cursor? (* -> boolean : mailbox-cursor))
    550 ;
    551539(define (mailbox-cursor? obj)
    552540  (%mailbox-cursor? obj) )
    553541
    554 (: mailbox-cursor-mailbox (mailbox-cursor --> mailbox))
    555 ;
    556542(define (mailbox-cursor-mailbox mbc)
    557543  (%mailbox-cursor-mailbox (%check-mailbox-cursor 'mailbox-cursor-mailbox mbc)) )
    558544
    559 (: mailbox-cursor-rewound? (mailbox-cursor -> boolean))
    560 ;
    561545(define (mailbox-cursor-rewound? mbc)
    562546  (not (%mailbox-cursor-winding? (%check-mailbox-cursor 'mailbox-cursor-rewound? mbc))) )
    563547
    564 (: mailbox-cursor-unwound? (mailbox-cursor -> boolean))
    565 ;
    566548(define (mailbox-cursor-unwound? mbc)
    567549  ($null? (%mailbox-cursor-next-pair (%check-mailbox-cursor 'mailbox-cursor-unwound? mbc))) )
     
    569551;; Mailbox Cursor Operations
    570552
    571 (: mailbox-cursor-rewind (mailbox-cursor -> void))
    572 ;
    573553(define (mailbox-cursor-rewind mbc)
    574554  (%mailbox-cursor-rewind! (%check-mailbox-cursor 'mailbox-cursor-rewind mbc)) )
    575555
    576 (: mailbox-cursor-next (mailbox-cursor #!optional timeout * -> *))
    577 ;
    578556(define (mailbox-cursor-next mbc #!optional timout (timout-value NO-TOVAL-TAG))
    579557  (when timout (%check-timeout 'mailbox-cursor-next timout))
     
    603581                res ) ) ) ) ) ) ) )
    604582
    605 (: mailbox-cursor-extract-and-rewind! (mailbox-cursor -> void))
    606 ;
    607583(define (mailbox-cursor-extract-and-rewind! mbc)
    608584  (%mailbox-cursor-extract! (%check-mailbox-cursor 'mailbox-cursor-extract-and-rewind! mbc))
  • release/5/mailbox/trunk/mailbox.egg

    r38956 r39006  
    55((synopsis "Thread-safe queues with timeout")
    66 (category hell)
    7  (version "3.3.6")
     7 (version "3.3.7")
    88 (author "[[felix winkelman]] and [[kon lovett]]")
    99 (license "BSD")
Note: See TracChangeset for help on using the changeset viewer.