Hi,

SRFI-18 states,

The mutex primitives specified in this SRFI do not implement "recursive" mutex 
semantics; an attempt to lock a mutex that is locked implies that the current 
thread must wait even if the mutex is owned by the current thread

so, I want a macro or procedure to support "recursive" mutex.
Would be glad someone can note on it.

Here's my macro, not sure if it works:
Isn't there a similar code?

(define my-mutex (make-mutex))
(define-macro (my-lock . body)
  `(let ([result #f])
     (if (eq? (mutex-state my-mutex) (current-thread))
         (set! result (begin ,@body))
         ;;else
         (begin
           (mutex-lock! my-mutex)
           (set! result (begin ,@body))
           (mutex-unlock! my-mutex)))
     result))


--daishi


_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to