From b642cb47275f5e98b82203e825d7dd57d571d65e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 19 Jul 2016 14:02:49 -0400 Subject: 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. --- Database/Keys/Handle.hs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Database/Keys') 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. -- cgit v1.2.3