Created
July 10, 2020 15:20
-
-
Save rbnpercy/3074a390b40f70181cfb567447c93101 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn task-queue | |
"Creates `core.async` channel which will process 0 arg functions put there in serial fashon. | |
Takes the same argument/s as `core.async/chan`, those arguments will be delegated to the | |
channel constructor. | |
Returns task-queue where tasks represented by 0 arg task functions can be put for processing." | |
[& args] | |
(let [task-queue (apply async/chan args)] | |
(async/go-loop [task-fn (async/<! task-queue)] | |
(run-task task-fn) | |
(recur (async/<! task-queue))) | |
task-queue)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment