Permalink
Browse files

added arnesi queue, in replacement of appending lists

  • Loading branch information...
1 parent 434fd90 commit 207ac3076117218a3a75cdcb050755c49dd98591 @kiuma committed Jun 8, 2011
Showing with 8 additions and 7 deletions.
  1. +7 −6 src/thread-pool.lisp
  2. +1 −1 thread-pool.asd
View
@@ -34,10 +34,10 @@
(defgeneric stop-pool (thread-pool)
(:documentation "Stops serving jobs"))
(defgeneric add-to-pool (thread-pool functions)
- :documentation "Add a function or a list of function to the thread pool")
+ (:documentation "Add a function or a list of function to the thread pool"))
(defclass thread-pool ()
- ((jobs :accessor jobs :initform ())
+ ((jobs :accessor jobs :initform (make-instance 'arnesi:queue))
(pool-size :reader pool-size :initarg :pool-size)
(threads :accessor threads :initform ())
(pool-condition-vars :accessor pool-condition-vars :initform ())
@@ -105,7 +105,7 @@
(func nil))
(bordeaux-threads:with-lock-held (pool-lock)
(setf (nth ix threads) nil
- func (pop jobs)))
+ func (arnesi:dequeue jobs)))
(when func
(funcall func))
(bordeaux-threads:with-lock-held (pool-lock)
@@ -133,8 +133,9 @@
(pool-condition pool-condition))
thread-pool
(bordeaux-threads:with-lock-held (pool-lock)
- (setf jobs (append jobs (if (listp functions)
- funtions
- (list functions)))))
+ (if (listp functions)
+ (dolist (func functions)
+ (arnesi:enqueue jobs func))
+ (arnesi:enqueue jobs functions)))
(print jobs)
(bordeaux-threads:condition-notify pool-condition)))
View
@@ -34,7 +34,7 @@
:license "Public Domain"
:author "Andrea Chiumenti"
:serial t
- :depends-on (#:bordeaux-threads)
+ :depends-on (#:bordeaux-threads #:arnesi)
:components ((:module src
:components ((:file "package")
(:file "thread-pool" :depends-on ("package"))))))

0 comments on commit 207ac30

Please sign in to comment.