From de7cd8220c364dd816f4136a9d4c5a4d6618359d Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Thu, 8 Mar 2018 23:06:12 -0300 Subject: Better routing and mutex --- src/clj/queue_api/db/core.clj | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/clj/queue_api/db') diff --git a/src/clj/queue_api/db/core.clj b/src/clj/queue_api/db/core.clj index adbda25..0ad9b81 100644 --- a/src/clj/queue_api/db/core.clj +++ b/src/clj/queue_api/db/core.clj @@ -156,7 +156,8 @@ [^String id] (let [a (d/entity @conn [:agent/id id])] (if-not (nil? a) - (let [jid (:job/id (fittest-job id))] - (end-job a) - (start-job id jid) - jid)))) \ No newline at end of file + (locking (Object.) + (let [jid (:job/id (fittest-job id))] + (end-job a) + (start-job id jid) + jid))))) \ No newline at end of file -- cgit v1.2.3