mirror of
https://github.com/penpot/penpot.git
synced 2026-05-15 21:13:58 +00:00
22 lines
643 B
Clojure
22 lines
643 B
Clojure
;; This Source Code Form is subject to the terms of the Mozilla Public
|
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
;;
|
|
;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>
|
|
|
|
(ns uxbox.locks
|
|
"Advirsory locks for specific handling concurrent modifications
|
|
on particular objects in the database."
|
|
(:require [suricatta.core :as sc])
|
|
(:import clojure.lang.Murmur3))
|
|
|
|
(defn- uuid->long
|
|
[v]
|
|
(Murmur3/hashUnencodedChars (str v)))
|
|
|
|
(defn acquire!
|
|
[conn v]
|
|
(let [id (uuid->long v)]
|
|
(sc/execute conn ["select pg_advisory_xact_lock(?);" id])
|
|
nil))
|