Permalink
Browse files

Merge branch 'clj-1.3'

  • Loading branch information...
ztellman committed Aug 8, 2012
2 parents e4e3d16 + 4383f0b commit 94579827d220c4e99f9c31b3d5d12e773cad7c8f
View
@@ -4,6 +4,6 @@ lib
classes
push
local-push
-DS_Store
+*DS_Store
autodoc
-.lein-failures
+.lein*
View
@@ -0,0 +1,4 @@
+language: clojure
+before_install:
+ - lein plugin install lein-multi 1.1.0
+script: lein multi test
View
@@ -1,9 +1,14 @@
-(defproject lamina "0.4.0"
+(defproject lamina "0.4.1"
:description "event-driven data structures for clojure"
- :dependencies [[org.clojure/clojure "1.2.0"]
- [org.clojure/clojure-contrib "1.2.0"]
- [potemkin "0.1.0"]]
- ;;:jvm-opts ["-agentlib:jdwp=transport=dt_socket,address=8030,server=y,suspend=n"]
+ :dependencies [[org.clojure/clojure "1.3.0"]
+ [org.clojure/tools.logging "0.2.3"]
+ [potemkin "0.1.3"]]
+ :multi-deps {:all [[org.clojure/tools.logging "0.2.3"]
+ [potemkin "0.1.3"]]
+ "1.2" [[org.clojure/clojure "1.2.1"]]}
+ :repositories {"sonatype-oss-public" "https://oss.sonatype.org/content/groups/public/"}
+ :exclusions [org.clojure/contrib
+ org.clojure/clojure-contrib]
:license {:name "Eclipse Public License - v 1.0"
:url "http://www.eclipse.org/legal/epl-v10.html"
- :distribution :repo})
+ :distribution :repo})
View
@@ -14,14 +14,14 @@
[lamina.core.channel :as channel]
[lamina.core.seq :as seq]))
-(import-fn #'pipeline/poll-result)
-(import-fn #'pipeline/success-result)
-(import-fn #'pipeline/error-result)
-(import-fn #'pipeline/success!)
-(import-fn #'pipeline/error!)
-(import-fn #'pipeline/closed-result)
-(import-fn #'pipeline/drained-result)
+(import-fn pipeline/poll-result)
+(import-fn pipeline/success-result)
+(import-fn pipeline/error-result)
+(import-fn pipeline/success!)
+(import-fn pipeline/error!)
+(import-fn pipeline/closed-result)
+(import-fn pipeline/drained-result)
-(import-fn #'seq/copy)
+(import-fn seq/copy)
-(import-fn #'channel/dequeue)
+(import-fn channel/dequeue)
@@ -51,7 +51,7 @@
(success! @result ::close)
(reset! result (success-result ::close))
(reset! latch false)
- (run-pipeline connection close))))
+ (run-pipeline connection #(when (channel? %) (close %))))))
;; run connection loop
(run-pipeline nil
@@ -76,6 +76,8 @@
(new-connection-callback ch))
(fn [_]
(future (success! @result ch))
+ (Thread/yield)
+ (when-not @latch (close ch))
(wait-for-close ch))))
;; wait here for connection to drop
(fn [_]
View
@@ -28,28 +28,28 @@
;;;; CHANNELS
;; core channel functions
-(import-fn #'channel/receive)
-(import-fn #'channel/cancel-callback)
-(import-fn #'channel/enqueue)
-(import-fn #'channel/enqueue-and-close)
-(import-fn #'channel/close)
-(import-fn #'channel/on-closed)
-(import-fn #'channel/on-drained)
-(import-fn #'channel/drained?)
-(import-fn #'channel/closed?)
-(import-fn #'channel/channel?)
-(import-fn #'seq/receive-all)
-(import-fn #'channel/poll)
+(import-fn channel/receive)
+(import-fn channel/cancel-callback)
+(import-fn channel/enqueue)
+(import-fn channel/enqueue-and-close)
+(import-fn channel/close)
+(import-fn channel/on-closed)
+(import-fn channel/on-drained)
+(import-fn channel/drained?)
+(import-fn channel/closed?)
+(import-fn channel/channel?)
+(import-fn seq/receive-all)
+(import-fn channel/poll)
;; channel variants
-(import-fn #'channel/splice)
-(import-fn #'channel/channel)
-(import-fn #'channel/channel-pair)
-(import-fn #'channel/permanent-channel)
-(import-fn #'channel/constant-channel)
-(import-fn #'channel/closed-channel)
-(import-fn #'channel/timed-channel)
-(import-fn #'channel/proxy-channel)
+(import-fn channel/splice)
+(import-fn channel/channel)
+(import-fn channel/channel-pair)
+(import-fn channel/permanent-channel)
+(import-fn channel/constant-channel)
+(import-fn channel/closed-channel)
+(import-fn channel/timed-channel)
+(import-fn channel/proxy-channel)
(def nil-channel channel/nil-channel)
@@ -76,45 +76,46 @@
(apply receive-all ch callbacks)
ch))
-(import-fn #'seq/fork)
-(import-fn #'seq/map*)
-(import-fn #'seq/filter*)
-(import-fn #'seq/remove*)
-(import-fn #'seq/receive-in-order)
-(import-fn #'seq/reduce*)
-(import-fn #'seq/reductions*)
-(import-fn #'seq/take*)
-(import-fn #'seq/take-while*)
-(import-fn #'seq/partition*)
-(import-fn #'seq/partition-all*)
-
-(import-fn #'op/sample-every)
+(import-fn seq/fork)
+(import-fn seq/mapcat*)
+(import-fn seq/map*)
+(import-fn seq/filter*)
+(import-fn seq/remove*)
+(import-fn seq/receive-in-order)
+(import-fn seq/reduce*)
+(import-fn seq/reductions*)
+(import-fn seq/take*)
+(import-fn seq/take-while*)
+(import-fn seq/partition*)
+(import-fn seq/partition-all*)
+
+(import-fn op/sample-every)
;; named channels
-(import-fn #'named/named-channel)
-(import-fn #'named/release-named-channel)
+(import-fn named/named-channel)
+(import-fn named/release-named-channel)
;; synchronous channel functions
-(import-fn #'seq/lazy-channel-seq)
-(import-fn #'seq/channel-seq)
-(import-fn #'seq/wait-for-message)
+(import-fn seq/lazy-channel-seq)
+(import-fn seq/channel-seq)
+(import-fn seq/wait-for-message)
;;;; PIPELINES
;; core pipeline functions
-(import-fn #'pipeline/result-channel)
-(import-fn #'pipeline/pipeline)
-(import-fn #'pipeline/run-pipeline)
+(import-fn pipeline/result-channel)
+(import-fn pipeline/pipeline)
+(import-fn pipeline/run-pipeline)
;; pipeline stage helpers
-(import-fn #'pipeline/result-channel?)
-(import-fn #'pipeline/read-channel)
+(import-fn pipeline/result-channel?)
+(import-fn pipeline/read-channel)
(def read-channel* read-channel)
-(import-fn #'pipeline/read-merge)
+(import-fn pipeline/read-merge)
-(import-fn #'pipeline/on-success)
-(import-fn #'pipeline/on-error)
+(import-fn pipeline/on-success)
+(import-fn pipeline/on-error)
(defmacro do-stage
"Creates a pipeline stage that emits the same value it receives, but performs some side-effect
@@ -124,16 +125,16 @@
~@body
x#))
-(import-fn #'pipeline/wait-stage)
+(import-fn pipeline/wait-stage)
;; redirect signals
-(import-fn #'pipeline/redirect)
-(import-fn #'pipeline/restart)
-(import-fn #'pipeline/complete)
+(import-fn pipeline/redirect)
+(import-fn pipeline/restart)
+(import-fn pipeline/complete)
;; pipeline result hooks
-(import-fn #'pipeline/wait-for-result)
-(import-fn #'pipeline/siphon-result)
+(import-fn pipeline/wait-for-result)
+(import-fn pipeline/siphon-result)
;;;
@@ -159,7 +160,7 @@
;;;
-(import-fn #'x-utils/compact)
+(import-fn x-utils/compact)
(defmacro force-all
"Forces a sequence of results. Subsequent expressions will wait on all results being
View
@@ -16,7 +16,7 @@
;;;
-(def *debug* false)
+(def ^{:dynamic true} *debug* false)
(defmacro debug-print [& args]
(when *debug*
@@ -58,7 +58,6 @@
(and
(seq? expr)
(< 1 (count expr))
- (symbol? (first expr))
(not (apply first= expr special-forms))))
(defn transform-expr [expr]
@@ -75,6 +74,7 @@
result#)
`(let [~@(apply concat non-constant-args)]
(run-pipeline []
+ :error-handler (fn [_#])
~@(map
(fn [arg]
`(read-merge
@@ -109,6 +109,7 @@
(if (= (resolve class-name) clojure.lang.LazySeq)
(transform-lazy-seq expr)
`(run-pipeline []
+ :error-handler (fn [_#])
~@(map
(fn [arg] `(read-merge (constantly ~arg) conj))
args)
@@ -118,6 +119,7 @@
(defn transform-throw [[_ exception]]
`(run-pipeline ~exception
+ :error-handler (fn [_#])
(fn [exception#]
(throw exception#))))
@@ -184,6 +186,7 @@
%)
body)))]
`(run-pipeline nil
+ :error-handler (fn [_#])
(fn [_#]
~body))))
@@ -92,6 +92,7 @@
(if (empty? dependencies)
expr*
`(run-pipeline nil
+ :error-handler (fn [_#])
~@(map
(fn [v] `(read-merge (constantly ~v) (constantly nil)))
dependencies)
@@ -14,9 +14,9 @@
(declare walk-exprs)
-(def *recur-point* nil)
-(def *final-walk* false)
-(def *special-walk-handlers* {})
+(def ^{:dynamic true} *recur-point* nil)
+(def ^{:dynamic true} *final-walk* false)
+(def ^{:dynamic true} *special-walk-handlers* {})
(defn walk-bindings [f bindings]
(vec
@@ -11,7 +11,7 @@
(:use
[clojure.walk])
(:require
- [clojure.contrib.logging :as log])
+ [clojure.tools.logging :as log])
(:import
[java.util.concurrent
ScheduledThreadPoolExecutor
@@ -42,19 +42,19 @@
(when message-callback
(message-callback msgs))
(catch Exception e
- (log/error "Error in message callback" e))))
+ (log/error e "Error in message callback"))))
(on-close [_]
(try
(when close-callback
(close-callback))
(catch Exception e
- (log/error "Error in close callback" e))))
+ (log/error e "Error in close callback"))))
(on-observers-changed [_ observers]
(try
(when observers-callback
(observers-callback observers))
(catch Exception e
- (log/error "Error in observers-changed callback" e)))))))
+ (log/error e "Error in observers-changed callback")))))))
;;;
@@ -195,11 +195,12 @@
(when-not (empty? msgs)
(let [msg (first msgs)]
(when (compare-and-set! val ::empty msg)
- (locking observers
- (let [s (vals @observers)]
- (reset! observers nil)
- (doseq [o s]
- (on-message o [msg])))))))
+ (let [s (locking observers
+ (let [s (vals @observers)]
+ (reset! observers nil)
+ s))]
+ (doseq [o s]
+ (on-message o [msg]))))))
false)
(close [this]
(message this [nil]))
Oops, something went wrong.

0 comments on commit 9457982

Please sign in to comment.