diff --git a/pkgdcl.lisp b/pkgdcl.lisp index 2dcf099700fb0045d6a8e9bf7bf22faa5007b38a..15a78fa4b450a383f77f7752a7fc30bf840962ff 100644 --- a/pkgdcl.lisp +++ b/pkgdcl.lisp @@ -18,5 +18,6 @@ #:handler-case* #:send-service-unavailable-reply) (:export + #:make-channel #:channel-send #:channel-recv #:start-thread #:thread-pooling-taskmaster)) diff --git a/thread-pooling.lisp b/thread-pooling.lisp index 197d4c7fd144d0257ff85c52e4c08bae9aeea784..bc87a237c66a4fcb934ff9e68a17f3577b9ea052 100644 --- a/thread-pooling.lisp +++ b/thread-pooling.lisp @@ -168,15 +168,22 @@ then the reply will be HTTP 503.")) (when dispatcher-process (dispatcher-send taskmaster '(:shutdown)))))) +(defun channel-send (channel message) + (lparallel.queue:push-queue message (lparallel.kernel::channel-queue channel))) + +(defun channel-recv (channel &key (blockp t)) + (let ((q (lparallel.kernel::channel-queue channel))) + (if blockp + (lparallel.queue:pop-queue q) + (lparallel.queue:try-pop-queue q)))) + (defgeneric dispatcher-send (taskmaster message &key &allow-other-keys) (:method ((taskmaster thread-pooling-taskmaster) message &key &allow-other-keys) - (lparallel.queue:push-queue - message - (lparallel.kernel::channel-queue (taskmaster-dispatcher-channel taskmaster))))) + (channel-send (taskmaster-dispatcher-channel taskmaster) message))) (defgeneric dispatcher-recv (taskmaster &key &allow-other-keys) (:method ((taskmaster thread-pooling-taskmaster) &key &allow-other-keys) - (receive-result (taskmaster-dispatcher-channel taskmaster)))) + (channel-recv (taskmaster-dispatcher-channel taskmaster)))) (defmethod execute-acceptor ((taskmaster thread-pooling-taskmaster)) (with-taskmaster-accessors