Closed niwinz closed 11 years ago
You can call (Fiber/sleep ms)
, or, better yet, (Strand/sleep ms)
, which will call Fiber/sleep
if you're in a fiber, and Thread/sleep
if you're in a thread. Clojure doesn't have a "Clojure-ish" sleep either, and relies instead on Java's Thread/sleep
, so we thought this is good enough.
You'll need to import the Strand
class from the co.paralleluniverse.strands
package (or the Fiber
class from the co.paralleluniverse.fibers
package).
Thanks for the explanation, but my idea is include one function like Srand/sleep on core namespace.
Why?
When I develop with clojure, I like to see more idiomatic code and avoid importing java classes. If I need some java integration, a make some wrapper in a clojure way.
It would not a bad idea include in core namespace a simple clojure function like this.
(defn sleep [ms]
(Strand/sleep ms))
With these simple function I can avoid import a java Strand class and use them sleep static method.
This is just an idea! Thanks.
Done.
Thanks!
It would be nice to have sleep function or core.async timeout function in core namespace.
Is there any reason that core ns should not have function like this?
Thanks! Andrey