Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/osc.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns osc
(:import
(java.util.concurrent TimeUnit TimeoutException PriorityBlockingQueue)
(java.util.concurrent TimeUnit TimeoutException LinkedBlockingQueue)
(java.net InetSocketAddress DatagramSocket DatagramPacket)
(java.nio.channels DatagramChannel AsynchronousCloseException ClosedChannelException)
(java.nio ByteBuffer ByteOrder))
Expand Down Expand Up @@ -152,7 +152,7 @@
(let [chan (DatagramChannel/open)
rcv-buf (ByteBuffer/allocate BUFFER-SIZE)
send-buf (ByteBuffer/allocate BUFFER-SIZE)
send-q (PriorityBlockingQueue. OSC-SEND-Q-SIZE (comparator (fn [a b] (< (:timestamp (second a)) (:timestamp (second b))))))
send-q (LinkedBlockingQueue.)
running? (ref true)
handlers (ref {})
listeners (ref #{(msg-handler-dispatcher handlers)})
Expand Down
22 changes: 21 additions & 1 deletion test/osc_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,31 @@
(osc-close server true)
(osc-close client true)))))

(deftest osc-slowpoke-server-test []
(let [server (osc-server PORT)
client (osc-client HOST PORT)
coll (atom [])
end 50
end-millis (+ (System/currentTimeMillis) (* end 1000 1/5))]
(try
(osc-handle server "/test" (fn [msg] (swap! coll (fn [s]
(Thread/sleep 100)
(conj s (first (:args msg)))))))
(dotimes [i end] (osc-send client "/test" i))
(while (or (not= (count @coll) end) (< (System/currentTimeMillis) end-millis))
(Thread/sleep 250))
(dorun (map-indexed #(is (= %1 %2)) @coll))
(finally
(osc-close server true)
(osc-close client true)))))


(defn osc-tests []
(binding [*test-out* *out*]
(run-tests 'osc-test)))

(defn test-ns-hook []
(osc-msg-test)
(thread-lifetime-test)
(osc-basic-test))
(osc-basic-test)
(osc-slowpoke-server-test))