(html (head (title "sph-lib (sph thread-pool)") (link (@ (rel "stylesheet") (type "text/css") (href "/css/sph.css"))) (meta (@ (name "viewport") (content "width=device-width,initial-scale=1"))) #f) (body () (div (@ (class top)) (nav (a (@ (href "/")) "start") ", " (a (@ (href "/feed.xml")) "feed")) "") (div (@ (class "middle")) (div (@ (class mtime) (title "last modification time of the current page")) "2023-04-05") (section (h1 "(sph thread-pool)") (div (p "thread-pool that uses wait-conditions to pause unused threads and has a customisable queue type") (p "part of " (a (@ (href "../../sph-lib.html")) "sph-lib")) (#f (section (@ (class "library-name")) (h1 "module name") (p "(sph thread-pool)")) (section (@ (class "library-exports")) (h1 "exported bindings") (div (div (@ (class "doc-bindings")) (div (@ (id "doc-b-" "sph-thread-pool-description") (class "doc-b")) (div (span (@ (class "type")) "variable") ": " (span (@ (class "name")) "sph-thread-pool-description")) "" "") (div (@ (id "doc-b-" "thread-pool-create") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "thread-pool-create") " " (span (@ (class "first-sig")) "[size exception-handler queue-type] ->")) (div (@ (class "rest-sig")) (div "[integer procedure:{key retry ->} true/symbol/(symbol ...) list/symbol:lifo/fifo] -> (procedure:{procedure:nullary:code-to-execute -> any/false}:enqueue! thread ...)")) (div (@ (class "description")) (("creates a list of threads that wait using condition variables to execute procedures from a queue, which is a first-in-first-out queue by default." (br) "the last-in-first-out queue just uses scheme lists and earlier tasks wait if there are not enough threads available to handle all tasks." (br) "the returned enqueue! procedure can be used to add procedures to the queue." (br) "if a procedure from the queue evaluates to false, the thread it was called in exits." (br) "by adding as many procedures like this as there are threads in the pool," (br) "all threads can be closed without having to cancel them by other more obscure means." (br) "the default size is the current processor count." (br) "queue-type can be a custom queue given as a list with the following signature" (br) "queue-type: (procedure:make-queue procedure:empty?:{queue -> boolean} procedure:enqueue:{queue a ->} procedure:dequeue:{queue -> any})")))) (div (@ (id "doc-b-" "thread-pool-finish") (class "doc-b")) (div (span (@ (class "type")) "procedure") ": " (span (@ (class "name")) "thread-pool-finish") " " (span (@ (class "first-sig")) "enqueue thread-list ->")) (div (@ (class "rest-sig")) (div "(thread ...) -> (thread-exit-value ...)")) (div (@ (class "description")) (("let threads complete all currently enqueued tasks and exit"))))))))))) ()))