diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-07-19 14:02:49 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-07-19 14:02:49 -0400 |
commit | b642cb47275f5e98b82203e825d7dd57d571d65e (patch) | |
tree | b462d17de42e9b73292d389436407d5a80e546fd /Database/Keys/Handle.hs | |
parent | 11b52352183e4206648225214d53fe2db7765a60 (diff) |
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.
Diffstat (limited to 'Database/Keys/Handle.hs')
-rw-r--r-- | Database/Keys/Handle.hs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Database/Keys/Handle.hs b/Database/Keys/Handle.hs index 1ef16d031..eec9e0fda 100644 --- a/Database/Keys/Handle.hs +++ b/Database/Keys/Handle.hs @@ -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. |