0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-15 09:11:21 -05:00

🚧 Minor changes on blocking calls for thumbnails generation.

This commit is contained in:
Andrey Antukh 2020-01-27 16:52:19 +01:00
parent aaa8bfe67d
commit bfe6b98ee1
2 changed files with 27 additions and 1 deletions

View file

@ -39,7 +39,9 @@
[rows]
(if (empty? rows)
rows
(p/all (map populate-thumbnail rows))))
(vc/blocking
(mapv (fn [row]
(images/populate-thumbnail row +thumbnail-options+)) rows))))
(defn populate-urls
[row]

View file

@ -57,6 +57,30 @@
[]
(Vertx/currentContext))
(defmacro blocking
[& body]
`(let [vsm# (-> (current-context)
(vu/resolve-system))
d# (p/deferred)]
(.executeBlocking
vsm#
(reify Handler
(handle [_ prm#]
(try
(.complete prm# (do ~@body))
(catch Throwable e#
(.fail prm# e#)))))
true
(reify Handler
(handle [_ ar#]
(if (.failed ^AsyncResult ar#)
(p/reject! d# (.cause ^AsyncResult ar#))
(p/resolve! d# (.result ^AsyncResult ar#))))))
d#))
(defn wrap-blocking
([f] (wrap-blocking (current-context) f))
([ctx f]