diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/clojure/org/gnu/clojure/gnunet/peer.clj | 6 | ||||
-rw-r--r-- | src/main/clojure/org/gnu/clojure/gnunet/topology_events.clj | 8 | ||||
-rw-r--r-- | src/main/clojure/org/gnu/clojure/gnunet/util.clj | 5 |
3 files changed, 11 insertions, 8 deletions
diff --git a/src/main/clojure/org/gnu/clojure/gnunet/peer.clj b/src/main/clojure/org/gnu/clojure/gnunet/peer.clj index fb98fd7..3cd1cf9 100644 --- a/src/main/clojure/org/gnu/clojure/gnunet/peer.clj +++ b/src/main/clojure/org/gnu/clojure/gnunet/peer.clj @@ -123,12 +123,10 @@ (defn selector-loop! [selector callbacks] - (doseq [callback (queue-seq! callbacks)] - (callback)) + (do-callbacks! (queue-seq! callbacks)) (.select selector) (let [selected-keys (.selectedKeys selector)] - (doseq [selection-key selected-keys] - ((.attachment selection-key))) + (do-callbacks! (map #(.attachment %) selected-keys)) (.clear selected-keys)) (recur selector callbacks)) diff --git a/src/main/clojure/org/gnu/clojure/gnunet/topology_events.clj b/src/main/clojure/org/gnu/clojure/gnunet/topology_events.clj index aaaf9a3..4d39c23 100644 --- a/src/main/clojure/org/gnu/clojure/gnunet/topology_events.clj +++ b/src/main/clojure/org/gnu/clojure/gnunet/topology_events.clj @@ -1,8 +1,8 @@ -(ns org.gnu.clojure.gnunet.topology_events) +(ns org.gnu.clojure.gnunet.topology_events + (:use org.gnu.clojure.gnunet.util)) (defn notify-new-remote-peer! [peer remote-peer] - (let [callbacks (:new-peer-callbacks (deref (:topology-agent peer)))] - (doseq [callback! callbacks] - (callback! peer remote-peer)))) + (do-callbacks! (:new-peer-callbacks (deref (:topology-agent peer))) + peer remote-peer)) diff --git a/src/main/clojure/org/gnu/clojure/gnunet/util.clj b/src/main/clojure/org/gnu/clojure/gnunet/util.clj index 9914dfd..3b4d5ff 100644 --- a/src/main/clojure/org/gnu/clojure/gnunet/util.clj +++ b/src/main/clojure/org/gnu/clojure/gnunet/util.clj @@ -50,3 +50,8 @@ (assoc _map _key (conj old-val (second kv))))) _map (partition 2 kvs))) + +(defn do-callbacks! + [callback-seq & args] + (doseq [callback! callback-seq] + (apply callback! args))) |