Permalink
Browse files

break apart concurrency examples into separate projects

  • Loading branch information...
1 parent 18f6900 commit 4166b0b9610d18fd325157b2b00157e68877e01c @cemerick cemerick committed Apr 3, 2012
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,8 @@
+(defproject com.clojurebook.concurrency.webcrawler "1.0.0-SNAPSHOT"
+ :description "A naive agent-based webcrawler, explored in chapter 4 of
+'Clojure Programming' by Emerick, Carper, and Grand."
+ :url "http://github.com/clojurebook/ClojureProgramming"
+ :dependencies [[org.clojure/clojure "1.3.0"]
+ [enlive "1.0.0"]]
+ :profiles {:1.4 {:dependencies [[org.clojure/clojure "1.4.0-beta6"]]}}
+ :main ^:skip-aot com.clojurebook.concurrency.webcrawler)
@@ -109,3 +109,15 @@
(Thread/sleep 60000)
(pause)
[(count @crawled-urls) (count url-queue)])
+
+(defn -main
+ [& [starting-url agent-count]]
+ (when-not starting-url
+ (println "Must provide a starting URL.
+e.g. `lein run http://www.bbc.co.uk [agent-count]`"))
+ (let [agent-count (or agent-count "10")
+ [crawled-count queued-count] (test-crawler (Integer/parseInt agent-count) starting-url)]
+ (println (format "Crawled %s URLs in 60 seconds, %s additional URLs left in the queue"
+ crawled-count queued-count))
+ (shutdown-agents)))
+

0 comments on commit 4166b0b

Please sign in to comment.