Last active
August 29, 2015 14:06
-
-
Save pjagielski/5864f55e179897819fdd 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
(ns file-counter.core | |
(:require [clojure.core.async :refer :all]) | |
(:gen-class)) | |
(defn count-files [count-chn path-chn path] | |
(doseq [file (.listFiles (java.io.File. path))] | |
(if (.isFile file) | |
(println (.getAbsolutePath file)) | |
(>!! path-chn (.getAbsolutePath file))))) | |
(defn run [path] | |
(let [count-chn (chan) path-chn (chan)] | |
(go | |
(while true | |
(let [path (<! path-chn)] | |
(go (count-files count-chn path-chn path))))) | |
(>!! path-chn path) | |
(<!! (timeout 10000)))) | |
(run "/tmp") | |
(defn -main [& args] | |
(run "/tmp")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment