slightly more efficient checking of versionUsesKeysDatabase
It's a mvar lookup either way, but I think this way will be slightly more efficient. And it reduces the number of places where it's checked to 1.
This commit is contained in:
parent
b0c805b3c2
commit
e34046de38
2 changed files with 13 additions and 10 deletions
|
@ -8,6 +8,7 @@
|
|||
module Database.Keys.Handle (
|
||||
DbHandle,
|
||||
newDbHandle,
|
||||
unavailableDbHandle,
|
||||
DbState(..),
|
||||
withDbState,
|
||||
flushDbQueue,
|
||||
|
@ -33,6 +34,9 @@ data DbState = DbClosed | DbOpen H.DbQueue | DbUnavailable
|
|||
newDbHandle :: IO DbHandle
|
||||
newDbHandle = DbHandle <$> newMVar DbClosed
|
||||
|
||||
unavailableDbHandle :: IO DbHandle
|
||||
unavailableDbHandle = DbHandle <$> newMVar DbUnavailable
|
||||
|
||||
-- Runs an action on the state of the handle, which can change its state.
|
||||
-- The MVar is empty while the action runs, which blocks other users
|
||||
-- of the handle from running.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue