Allegro: move thread functions after locking functions
authorStelian Ionescu <sionescu@cddr.org>
Mon, 26 Mar 2012 14:36:53 +0000 (16:36 +0200)
committerStelian Ionescu <sionescu@cddr.org>
Mon, 26 Mar 2012 14:36:53 +0000 (16:36 +0200)
src/impl-allegro.lisp

index 2c0b09d..9470528 100644 (file)
@@ -11,36 +11,6 @@ Distributed under the MIT license (see LICENSE file)
 ;;; documentation on the Allegro Multiprocessing interface can be found at
 ;;; http://www.franz.com/support/documentation/8.1/doc/multiprocessing.htm
 
-(deftype thread ()
-  'mp:process)
-
-;;; Thread Creation
-
-(defun start-multiprocessing ()
-  (mp:start-scheduler))
-
-(defvar *thread-results* (make-hash-table :weak-keys t))
-
-(defvar *thread-join-lock* (make-lock :name "Bordeaux threads join lock"))
-
-(defun %make-thread (function name)
-  (mp:process-run-function
-   name
-   (lambda ()
-     (let ((result (funcall function)))
-       (with-lock-held (*thread-join-lock*)
-         (setf (gethash (current-thread) *thread-results*)
-               result))))))
-
-(defun current-thread ()
-  mp:*current-process*)
-
-(defun threadp (object)
-  (typep object 'mp:process))
-
-(defun thread-name (thread)
-  (mp:process-name thread))
-
 ;;; Resource contention: locks and recursive locks
 
 (defun make-lock (&optional name)
@@ -81,6 +51,36 @@ Distributed under the MIT license (see LICENSE file)
 (defun thread-yield ()
   (mp:process-allow-schedule))
 
+(deftype thread ()
+  'mp:process)
+
+;;; Thread Creation
+
+(defun start-multiprocessing ()
+  (mp:start-scheduler))
+
+(defvar *thread-results* (make-hash-table :weak-keys t))
+
+(defvar *thread-join-lock* (make-lock :name "Bordeaux threads join lock"))
+
+(defun %make-thread (function name)
+  (mp:process-run-function
+   name
+   (lambda ()
+     (let ((result (funcall function)))
+       (with-lock-held (*thread-join-lock*)
+         (setf (gethash (current-thread) *thread-results*)
+               result))))))
+
+(defun current-thread ()
+  mp:*current-process*)
+
+(defun threadp (object)
+  (typep object 'mp:process))
+
+(defun thread-name (thread)
+  (mp:process-name thread))
+
 ;;; Timeouts
 
 (defmacro with-timeout ((timeout) &body body)