Skip to content

Instantly share code, notes, and snippets.

@nikodemus
Created August 16, 2011 12:49
Show Gist options
  • Save nikodemus/1148996 to your computer and use it in GitHub Desktop.
Save nikodemus/1148996 to your computer and use it in GitHub Desktop.
user-space CONDITION-WAIT sketch
(defun condition-wait (waitqueue lock &key timeout)
(release-lock lock)
(let ((self *current-thread*))
(unwind-protect
(progn
(enqueue self waitqueue)
(when (wait-for (eq self (queue-first waitqueue))
:timeout timeout)
(grab-lock lock :timeout timeout)))
(delete-from-queue self))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment