Created
February 12, 2012 20:38
-
-
Save reiddraper/1810761 to your computer and use it in GitHub Desktop.
async IO + thread pool
This file contains hidden or 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 chat.core | |
| (:use lamina.core aleph.tcp gloss.core) | |
| (:gen-class)) | |
| (def broadcast-channel (permanent-channel)) | |
| (defn chat-handler [ch client-info] | |
| (receive-all ch #(async (let [value (if (not= "sleep" %) | |
| % | |
| (task (do (Thread/sleep 5000) "I slept!")))] | |
| (enqueue broadcast-channel value) | |
| ))) | |
| (siphon broadcast-channel ch)) | |
| (defn -main [& args] | |
| (start-tcp-server chat-handler {:port 5000 :frame (string :utf-8 :delimiters ["\r\n"])})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment