remove lock and use atomic-incf

This commit is contained in:
David Botton 2022-08-10 00:26:24 -04:00
parent 91b229133d
commit 91e228e3f6
2 changed files with 3 additions and 5 deletions

View file

@ -9,7 +9,7 @@
:depends-on (#:clack #:websocket-driver #:alexandria #:hunchentoot #:cl-ppcre
#:bordeaux-threads #:trivial-open-browser #:parse-float #:quri
#:lack-middleware-static #:lack-request #:lack-util-writer-stream
#:closer-mop #:mgl-pax #:cl-template
#:closer-mop #:mgl-pax #:cl-template #:atomics
#:sqlite #:cl-dbi #:cl-pass #:cl-isaac)
:components ((:module "static-files"
:components ((:static-file "js/boot.js")))

View file

@ -87,9 +87,7 @@ script."
(defvar *connection-ids* (make-hash-table* :test #'equal) "IDs to connections")
(defvar *connection-data* (make-hash-table* :test #'equal) "Connection based data")
(defvar *new-id* 0 "Last issued connection or script IDs")
(defvar *id-lock* (bordeaux-threads:make-lock)
"Protect new-id variable.")
(defvar *new-id* '(0) "Last issued connection or script IDs")
#-(or mswindows win32 cormanlisp) ; isaac hasn't supported these platforms
(defparameter *isaac-ctx*
@ -126,7 +124,7 @@ script."
(defun generate-id ()
"Generate unique ids for use in scripts."
(bordeaux-threads:with-lock-held (*id-lock*) (incf *new-id*)))
(atomics:atomic-incf (car *new-id*)))
;;;;;;;;;;;;;;;;:;;;;;;
;; random-hex-string ;;