[slime-devel] patch for openmcl backend

bryan o'connor bryan-slime at lunch.org
Wed Feb 4 21:52:46 UTC 2004

the openmcl backend was using ccl:process-wait for the
control thread which would spike cpu usage while idling.
(and more annoyingly cause the fans on my powerbook to
spin up)

i added a semaphore and use that instead to signal new
data to be received.


Index: swank-openmcl.lisp
RCS file: /project/slime/cvsroot/slime/swank-openmcl.lisp,v
retrieving revision 1.58
diff -u -r1.58 swank-openmcl.lisp
--- swank-openmcl.lisp	31 Jan 2004 15:07:35 -0000	1.58
+++ swank-openmcl.lisp	4 Feb 2004 21:38:13 -0000
@@ -590,6 +590,7 @@

  (defstruct (mailbox (:conc-name mailbox.))
    (mutex (ccl:make-lock "thread mailbox"))
+  (semaphore (ccl:make-semaphore))
    (queue '() :type list))

  (defimplementation spawn (fn &key name)
@@ -640,11 +641,12 @@
           (mutex (mailbox.mutex mbox)))
      (ccl:with-lock-grabbed (mutex)
        (setf (mailbox.queue mbox)
-            (nconc (mailbox.queue mbox) (list message))))))
+            (nconc (mailbox.queue mbox) (list message)))
+      (ccl:signal-semaphore (mailbox.semaphore mbox)))))

  (defimplementation receive ()
    (let* ((mbox (mailbox ccl:*current-process*))
           (mutex (mailbox.mutex mbox)))
-    (ccl:process-wait "receive" #'mailbox.queue mbox)
+    (ccl:wait-on-semaphore (mailbox.semaphore mbox))
      (ccl:with-lock-grabbed (mutex)
        (pop (mailbox.queue mbox)))))

More information about the slime-devel mailing list