Public Vars

Back

await-for (clj)

(source)

function

(await-for timeout-ms & agents)
Blocks the current thread until all actions dispatched thus far (from this thread or agent) to the agents have occurred, or the timeout (in milliseconds) has elapsed. Returns logical false if returning due to timeout, logical true otherwise.

Examples

typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
  "Type annotations for the base Clojure distribution."
  #?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
  (:require [clojure.core :as cc]
            [typed.clojure :as t]
            #?(:clj [typed.ann-macros.clojure :as macros])
            #?(:clj typed.ann.clojure.jvm) ;; jvm annotations
            #?(:clj clojure.core.typed))
  #?(:clj
     (:import (clojure.lang PersistentHashSet PersistentList
                            APersistentMap #_IPersistentCollection
                            #_ITransientSet
                            IRef)
              (java.util Comparator Collection))))

#?@(:cljs [] :default [
cc/get-thread-bindings [:-> (t/Map t/AnyVar t/Any)]
cc/bound-fn*
    (t/All [r b :..]
         [[b :.. b :-> r] :-> [b :.. b :-> r]])
cc/find-var
    [t/Sym :-> (t/Nilable t/AnyVar)]
cc/agent
    (t/All [x] [x & :optional {:validator (t/Nilable [x :-> t/Any]) :meta t/Any
                               :error-handler (t/Nilable [(t/Agent x) Throwable :-> t/Any])
                               :error-mode (t/U ':continue ':fail)} 
                :-> (t/Agent x)])
cc/set-agent-send-executor! [java.util.concurrent.ExecutorService :-> t/Any]
cc/set-agent-send-off-executor! [java.util.concurrent.ExecutorService :-> t/Any]
cc/send-via (t/All [x b :..] [(t/Agent x) [x b :.. b :-> x] b :.. b :-> (t/Agent x)])
cc/send (t/All [x b :..] [(t/Agent x) [x b :.. b :-> x] b :.. b :-> (t/Agent x)])
cc/send-off (t/All [x b :..] [(t/Agent x) [x b :.. b :-> x] b :.. b :-> (t/Agent x)])
cc/await [t/AnyAgent :* :-> nil]
cc/await-for [t/AnyInteger t/AnyAgent :* :-> t/Bool]
cc/await1 (t/All [[a :< t/AnyAgent]] [a :-> (t/Nilable a)])
cc/release-pending-sends [:-> t/AnyInteger]
])