Public Vars

Back

cycle (clj)

(source)

function

(cycle coll)
Returns a lazy (infinite!) sequence of repetitions of the items in coll.

Examples

puppetlabs/trapperkeeper
(ns puppetlabs.trapperkeeper.app
  (:require [schema.core :as schema]
            [puppetlabs.trapperkeeper.services :as s]
            [clojure.core.async.impl.protocols :as async-prot])
  (:import (clojure.lang IDeref)))

(def TrapperkeeperAppContext
  "Schema for a Trapperkeeper application's internal context.  NOTE: this schema
  is intended for internal use by TK and may be subject to minor changes in future
  releases."
  {:service-contexts {schema/Keyword {schema/Any schema/Any}}
   :ordered-services TrapperkeeperAppOrderedServices
   :services-by-id {schema/Keyword (schema/protocol s/Service)}
   :lifecycle-channel (schema/protocol async-prot/Channel)
   :shutdown-channel (schema/protocol async-prot/Channel)
   :lifecycle-worker (schema/protocol async-prot/Channel)
   :shutdown-reason-promise IDeref})
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))))

cc/cycle (t/All [x] [(t/Seqable x) :-> (t/NonEmptyASeq x)])
ReactiveX/RxClojure
(ns rx.lang.clojure.graph-test
  (:require [rx.lang.clojure.graph :as graph]
            [rx.lang.clojure.core :as rx]
            [rx.lang.clojure.future :as rx-future]
            [rx.lang.clojure.blocking :as rx-blocking]
            [clojure.test :refer [deftest testing is]]))

(deftest test-let-o*
  (testing "throws on cycle"
    (is (thrown-with-msg? IllegalArgumentException #"Cycle found"
                          (graph/let-o* {:a {:deps [:a]}}))))
eponai/sulolive
(ns eponai.server.external.datomic
  (:require [com.stuartsierra.component :as component]
            [eponai.server.datomic-dev :as datomic-dev]
            [eponai.common.database :as db]
            [datomic.api :as datomic]
            [suspendable.core :as suspendable]
            [clojure.core.async :as async]
            [taoensso.timbre :refer [debug error]])
  (:import (java.util.concurrent BlockingQueue)))

  component/Lifecycle
  (start [this]
    (if (:conn this)
      this
      (let [conn (or provided-conn
                     (datomic-dev/create-connection db-url
                                                    {::datomic-dev/add-data? add-mocked-data?}))
            tx-listeners (atom {})
            control-chan (async/chan)
            tx-report-queue (datomic/tx-report-queue conn)]
        (async/thread
          (try
            (loop []
              (let [tx-report (.take ^BlockingQueue tx-report-queue)]
                (when-not (= ::finished tx-report)
                  (->>
                    (deref tx-listeners)
                    (vals)
                    (run!
                      (fn [{:keys [on-tx-report on-error]}]
                        (try
                          (on-tx-report tx-report)
                          (catch Throwable e
                            (error "Error in DatomicChat thread reading tx-report-queue: " e)
                            (try
                              (on-error e)
                              (catch Throwable e
                                (error "on-error threw exception, really?: " e))))))))
                  (recur))))
            (catch InterruptedException e
              (error "Error in DatomicChat thread reading tx-report-queue: " e)))
          (debug "Exiting Datomic async/thread..")
          (async/close! control-chan))
        (assoc this :conn conn
                    :control-chan control-chan
                    :tx-listeners tx-listeners
                    :tx-report-queue tx-report-queue))))
  (stop [this]
    (when-let [conn (:conn this)]
      (datomic/remove-tx-report-queue conn)
      ;; Adding ::finished to will eventually close the control-chan
      (.add ^BlockingQueue (:tx-report-queue this) ::finished)
      (let [[v c] (async/alts!! [(:control-chan this) (async/timeout 1000)])]
        (if (= c (:control-chan this))
          (debug "Datomic report-queue successfully stopped.")
          (debug "Datomic report-queue timed out when stopping.")))
      (datomic/release conn))
    (dissoc this :conn :control-chan :tx-listeners :tx-report-queue))