aboutsummaryrefslogtreecommitdiff
path: root/src/clj/queue_api/db/core.clj
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2018-03-08 23:06:12 -0300
committerGabriel A. Giovanini <mail@gabrielgio.me>2018-03-08 23:06:12 -0300
commitde7cd8220c364dd816f4136a9d4c5a4d6618359d (patch)
tree8de2745e1d6d63d020330ad71f8bc6fe5e37db08 /src/clj/queue_api/db/core.clj
parentb9e1725e4f9bebce7e426431a1f8524efd026662 (diff)
downloadqueue-api-de7cd8220c364dd816f4136a9d4c5a4d6618359d.tar.gz
queue-api-de7cd8220c364dd816f4136a9d4c5a4d6618359d.tar.bz2
queue-api-de7cd8220c364dd816f4136a9d4c5a4d6618359d.zip
Better routing and mutex
Diffstat (limited to 'src/clj/queue_api/db/core.clj')
-rw-r--r--src/clj/queue_api/db/core.clj9
1 files changed, 5 insertions, 4 deletions
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