source: project/release/5/synch/trunk/synch-object.scm @ 38608

Last change on this file since 38608 was 38608, checked in by Kon Lovett, 3 months ago

add make-exchanger (in only module w/ disable-interrupts), strict-types, style, use symbol-append

File size: 1.0 KB
Line 
1;;;; synch-object.scm
2;;;; Kon Lovett, Dec '18
3
4(module synch-object
5
6(;export
7  datum-unbound-value?
8  mutex-with-object?
9  make-synch-with-object
10  synch-with-object? check-synch-with-object error-synch-with-object)
11
12(import scheme)
13(import (chicken base))
14(import (only (srfi 18)
15  make-mutex mutex?
16  mutex-specific mutex-specific-set!))
17(import (only type-checks define-check+error-type))
18
19;;;
20
21;;
22
23(define (datum-unbound-value? datum)
24  (or (eq? (void) datum) (not datum)) )
25
26(define (mutex-with-object? obj)
27  (and
28    (mutex? obj)
29    (not (datum-unbound-value? (mutex-specific obj))) ) )
30
31;;
32
33(define (make-synch-with-object obj #!optional (name '(synchobj)))
34  (let* (
35    (name (if (pair? name) (gensym (car name)) name) )
36    (mutex (make-mutex name) ) )
37    (mutex-specific-set! mutex obj)
38    mutex ) )
39
40(define (synch-with-object? obj #!optional pred)
41  (and
42    (mutex-with-object? obj)
43    (or
44      (not pred)
45      (pred (mutex-specific obj)) ) ) )
46
47(define-check+error-type synch-with-object)
48
49) ;module synch-object
Note: See TracBrowser for help on using the repository browser.