All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.alphatier.java.constraints.clj Maven / Gradle / Ivy

Go to download

Alphatier is a resource management library. It is designed to allow different schedulers to share the resources of a pool of executors in order to execute tasks with those.

There is a newer version: 0.2.0
Show newest version
(ns io.alphatier.java.constraints
  (:require [io.alphatier.constraints :as constraints]
            [io.alphatier.java.mappings :as mappings])
  (:gen-class
    :name io.alphatier.java.InternalConstraints
    :implements [io.alphatier.java.Constraints])
  (:import (io.alphatier.java Pool PreConstraint PostConstraint ConstraintType)))

(defmulti -add class)

(defmethod -add PreConstraint [_ ^Pool pool ^String name ^PreConstraint constraint]
  (constraints/add (.getPool pool) :pre (keyword name)
                   (fn [commit pre-snapshot]
                     (map mappings/from-CommitTask
                          (.check constraint
                                  (mappings/to-original commit)
                                  (mappings/to-LazySnapshot pre-snapshot))))))

(defmethod -add PostConstraint [_ ^Pool pool ^String name ^PostConstraint constraint]
  (constraints/add (.getPool pool) :post (keyword name)
                   (fn [commit pre-snapshot post-snapshot]
                     (map mappings/from-CommitTask
                          (.check constraint
                                  (mappings/to-original commit)
                                  (mappings/to-LazySnapshot pre-snapshot)
                                  (mappings/to-LazySnapshot post-snapshot))))))

(defn -del [_ ^Pool pool ^String name ^ConstraintType type]
  (constraints/del (.getPool pool) (mappings/from-ConstraintType type) (keyword name)))




© 2015 - 2024 Weber Informatics LLC | Privacy Policy