chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] recursive mutex-lock!


From: Daishi Kato
Subject: [Chicken-users] recursive mutex-lock!
Date: Mon, 25 Feb 2008 17:19:55 +0900
User-agent: Wanderlust/2.15.5 (Almost Unreal) Emacs/21.4 Mule/5.0 (SAKAKI)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]