summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hintz <t@thintz.com>2020-04-28 17:27:48 -0700
committerThomas Hintz <t@thintz.com>2020-04-28 17:27:48 -0700
commit856ab034d5c7b73e0fd86c4e1a3e9d8af92f3d00 (patch)
tree82b2c91d9a2a33c98fd9a66a18577ac2ec833854
parent11361fd8147e7238e2308f26654f09f9679ca022 (diff)
downloadfarm-856ab034d5c7b73e0fd86c4e1a3e9d8af92f3d00.tar.gz
Ensure amb+ is protected with mutex.
-rw-r--r--src/server/farm.scm27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/server/farm.scm b/src/server/farm.scm
index ec623c2..103632e 100644
--- a/src/server/farm.scm
+++ b/src/server/farm.scm
@@ -96,6 +96,14 @@
(lambda () (set! (,(first (second x)) obj) res))
(lambda () (mutex-unlock! mutex))))))))
+(define-syntax with-app
+ (syntax-rules ()
+ ((_ (app) body ...)
+ (dynamic-wind
+ (lambda () (mutex-lock! (app-mutex app)))
+ (lambda () body ...)
+ (lambda () (mutex-unlock! (app-mutex app)))))))
+
(define-record player
(setter cash)
(setter display-cash)
@@ -2303,6 +2311,7 @@
(player-stats p)))))
(define (get-actions player space)
+ (with-app (*app*)
(let ((res '()))
(let loop ((a
(prolog+meta
@@ -2408,7 +2417,7 @@
`((,(list-ref *months* space) ?action tom ?value)))))
(if a
(begin (set! res (cons a res)) (loop (amb+)))
- res))))
+ res)))))
(define (normalize-crop crop)
(cond ((or (eq? crop 'wheat) (eq? crop 'corn))
@@ -2625,24 +2634,8 @@
;; TODO
;; make sure two players can't have the same name
-;; "your turn to roll" showing up on mobile when on action screen
;; bug on display for uncle berts farm
;; Error: (mailbox-send!) bad argument type - not a mailbox: "redhead91
;; farmers luck can cause display cash to be out of sync
-
-;; Uncaught TypeError: Cannot read property 'toFixed' of undefined
-;; at St (app.0f8d4f4543faaee5dff1.js:1377)
-;; at app.0f8d4f4543faaee5dff1.js:1457
-;; at Object.y [as dispatch] (vendors.bef6ac3591b4d9cb3c76.js:8936)
-;; at app.0f8d4f4543faaee5dff1.js:1226
-;; at eu (vendors.bef6ac3591b4d9cb3c76.js:12601)
-;; at WebSocket.pt (app.0f8d4f4543faaee5dff1.js:1127)
-
-;; Uncaught TypeError: Cannot read property 'krispy kreme' of undefined
-;; at app.0f8d4f4543faaee5dff1.js:1461
-;; at Object.y [as dispatch] (vendors.bef6ac3591b4d9cb3c76.js:8936)
-;; at app.0f8d4f4543faaee5dff1.js:1226
-;; at eu (vendors.bef6ac3591b4d9cb3c76.js:12601)
-;; at WebSocket.pt (app.0f8d4f4543faaee5dff1.js:1127)