Created
August 16, 2011 12:49
-
-
Save nikodemus/1148996 to your computer and use it in GitHub Desktop.
user-space CONDITION-WAIT sketch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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