hunk ./package.lisp 5 - #:%thread-pool-soft-limit) + #:*thread-pool* #:thread-limit + #:thread-pool #:fixed-fifo-thread-pool) hunk ./threads.lisp 6 - (soft-limit :accessor soft-limit :initform nil) + (thread-limit :accessor thread-limit :initform nil) hunk ./threads.lisp 13 -(define-symbol-macro %thread-pool-soft-limit (soft-limit *thread-pool*)) - hunk ./threads.lisp 20 - (if (and (soft-limit thread-pool) - (> (length (threads thread-pool)) - (soft-limit thread-pool))) - (return) - (incf (free-thread-counter thread-pool))) + (when (and (thread-limit thread-pool) + (> (length (threads thread-pool)) + (thread-limit thread-pool))) + (return)) + (incf (free-thread-counter thread-pool)) hunk ./threads.lisp 35 - :name "Eager Futures Thread Pool Worker") + :name (format nil "Eager Future ~A Worker" + (class-name (class-of thread-pool)))) hunk ./threads.lisp 39 -(defmethod assign-task (task (thread-pool thread-pool)) +(defmethod assign-task :around (task (thread-pool thread-pool)) hunk ./threads.lisp 41 - (if (= (free-thread-counter thread-pool) (length (tasks thread-pool))) - (new-worker-thread thread-pool task) - (push task (tasks thread-pool))) + (call-next-method) hunk ./threads.lisp 43 + +(defmethod assign-task (task (thread-pool thread-pool)) + (if (= (free-thread-counter thread-pool) (length (tasks thread-pool))) + (new-worker-thread thread-pool task) + (push task (tasks thread-pool)))) + +(defclass fixed-fifo-thread-pool (thread-pool) + ()) + +(defmethod assign-task (task (thread-pool fixed-fifo-thread-pool)) + (if (and (= (free-thread-counter thread-pool) (length (tasks thread-pool))) + (or (null (thread-limit thread-pool)) + (< (length (threads thread-pool)) (thread-limit thread-pool)))) + (new-worker-thread thread-pool task) + (setf (tasks thread-pool) (append (tasks thread-pool) (list task)))))