Changeset 7742
- Timestamp:
- Nov 24, 2007, 6:35:25 PM (17 years ago)
- File:
-
- 1 edited
-
branches/working-0711/ccl/lib/macros.lisp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/working-0711/ccl/lib/macros.lisp
r7681 r7742 2348 2348 the lock held." 2349 2349 (declare (ignore whostate)) 2350 `(with-lock-context 2351 (with-recursive-lock (,lock) ,@body))) 2350 (let* ((locked (gensym)) 2351 (l (gensym))) 2352 ` (with-lock-context 2353 (let ((,locked (make-lock-acquisition)) 2354 (,l ,lock)) 2355 (declare (dynamic-extent ,locked)) 2356 (unwind-protect 2357 (progn 2358 (%lock-recursive-lock-object ,l ,locked ) 2359 ,@body) 2360 (when (lock-acquisition.status ,locked) (%unlock-recursive-lock-object ,l))))))) 2352 2361 2353 2362 (defmacro with-lock-grabbed-maybe ((lock &optional … … 2355 2364 &body body) 2356 2365 (declare (ignore whostate)) 2357 `(with-lock-context 2358 (with-recursive-lock-maybe (,lock) ,@body))) 2366 (let* ((l (gensym))) 2367 `(with-lock-context 2368 (let* ((,l ,lock)) 2369 (when (%try-recursive-lock-object ,l) 2370 (unwind-protect 2371 (progn ,@body) 2372 (%unlock-recursive-lock-object ,l))))))) 2359 2373 2360 2374 (defmacro with-standard-abort-handling (abort-message &body body) … … 2601 2615 nil)) 2602 2616 2603 (defmacro with-hash-write-lock ((hash) &body body) 2604 `(with-write-lock ((nhash.exclusion-lock ,hash)) 2605 ,@body)) 2606 2607 ;;; To ... er, um, ... expedite implementation, we lock the hash 2608 ;;; table exclusively whenever touching it. For now. 2609 2610 (defmacro with-exclusive-hash-lock ((hash) &body body) 2611 `(with-hash-write-lock (,hash) ,@body)) 2617 2612 2618 2613 2619 (defmacro with-hash-table-iterator ((mname hash-table) &body body &environment env) … … 2618 2624 any objects remain in the hash table. When the first value is non-NIL, 2619 2625 the second and third values are the key and the value of the next object." 2620 (let ((state (gensym)) 2621 (htab (gensym))) 2622 (multiple-value-bind (body decls) (parse-body body env) 2623 `(let* ((,htab ,hash-table) 2624 (,state (vector nil nil nil 2625 nil nil))) 2626 (declare (dynamic-extent ,state)) 2627 (unwind-protect 2628 (macrolet ((,mname () `(do-hash-table-iteration ,',state))) 2629 (start-hash-table-iterator ,htab ,state) 2630 (locally ,@decls ,@body)) 2631 (finish-hash-table-iterator ,state)))))) 2626 (let* ((hash (gensym)) 2627 (keys (gensym)) 2628 (state (gensym))) 2629 `(let* ((,hash ,hash-table) 2630 (,keys (make-array (the fixnum (hash-table-count ,hash)))) 2631 (,state (vector ,hash 0 ,keys (enumerate-hash-keys ,hash ,keys)))) 2632 (declare (dynamic-extent ,keys ,state)) 2633 (macrolet ((,mname () `(next-hash-table-iteration ,',state))) 2634 ,@body)))) 2635 2632 2636 2633 2637 (eval-when (compile load eval) … … 2990 2994 (setf (%process-whostate ,p) ,old-whostate))))) 2991 2995 2992 (defmacro %with-recursive-lock-ptr ((lockptr) &body body) 2993 (let* ((locked (gensym))) 2994 `(let ((,locked (make-lock-acquisition))) 2995 (declare (dynamic-extent ,locked)) 2996 (unwind-protect 2997 (progn 2998 (%lock-recursive-lock ,lockptr ,locked ) 2999 ,@body) 3000 (when (lock-acquisition.status ,locked) (%unlock-recursive-lock ,lockptr)))))) 3001 3002 (defmacro %with-recursive-lock-ptr-maybe ((lockptr) &body body) 3003 `(when (%try-recursive-lock ,lockptr) 3004 (unwind-protect 3005 (progn ,@body) 3006 (%unlock-recursive-lock ,lockptr)))) 3007 3008 3009 (defmacro with-recursive-lock ((lock) &body body) 3010 (let* ((p (gensym))) 3011 `(let* ((,p (recursive-lock-ptr ,lock))) 3012 (%with-recursive-lock-ptr (,p) ,@body)))) 3013 3014 (defmacro with-recursive-lock-maybe ((lock) &body body) 3015 (let* ((p (gensym))) 3016 `(let* ((,p (recursive-lock-ptr ,lock))) 3017 (%with-recursive-lock-ptr-maybe (,p) ,@body)))) 2996 2997 2998 3018 2999 3019 3000 (defmacro with-read-lock ((lock) &body body) … … 3036 3017 `(with-lock-context 3037 3018 (let* ((,p ,lock)) 3038 (unwind-protect3039 (progn3040 (write-lock-rwlock ,p)3041 ,@body)3042 (unlock-rwlock ,p))))))3019 (unwind-protect 3020 (progn 3021 (write-lock-rwlock ,p) 3022 ,@body) 3023 (unlock-rwlock ,p)))))) 3043 3024 3044 3025
Note:
See TracChangeset
for help on using the changeset viewer.
