In process locking implemented, not sqlite locking.

This commit is contained in:
2026-08-31 15:37:54 +02:00
parent 3f468504a6
commit 0b45c8b286
4 changed files with 89 additions and 7 deletions
+22 -1
View File
@@ -83,6 +83,18 @@ Returns all keys.
Returns all key-value pairs.
}
@defmethod[(with-lock [proc (-> any/c)]) any/c]{
Calls @racket[proc] while holding the lock belonging to this keystore
object and returns the value produced by @racket[proc]. Other threads
using @method[keystore% with-lock] on the same object wait until the lock is
released.
The lock is reentrant for nested calls on the same thread and is
released when control leaves @racket[proc], including when an exception
is raised. Keystore methods do not acquire this lock automatically.
}
}
@section{Examples}
@@ -115,4 +127,13 @@ Returns all key-value pairs.
@racketblock[
(send ks glob "*b*")
(send ks glob-kv "*b*")
]
]
@subsection{Locking}
@racketblock[
(send ks with-lock
(λ ()
(send ks set! 'counter
(add1 (send ks get 'counter 0)))))
]