chickadee » srfi-18 » mutex-state

mutex-state mutexprocedure

Returns information about the state of the mutex. The possible results are:

  • thread T: the mutex is in the locked/owned state and thread T is the owner of the mutex
  • symbol not-owned: the mutex is in the locked/not-owned state
  • symbol abandoned: the mutex is in the unlocked/abandoned state
  • symbol not-abandoned: the mutex is in the unlocked/not-abandoned state
    (mutex-state (make-mutex))  ==>  not-abandoned
 
    (define (thread-alive? thread)
      (let ((mutex (make-mutex)))
        (mutex-lock! mutex #f thread)
        (let ((state (mutex-state mutex)))
          (mutex-unlock! mutex) ; avoid space leak
          (eq? state thread))))