mirror of
https://github.com/ilyakooo0/vty.git
synced 2024-11-29 08:49:40 +03:00
UnicodeWidthTable.Install: clean up lock use
This commit is contained in:
parent
5772d6aa57
commit
84e391f56a
@ -28,9 +28,11 @@ installLock = unsafePerformIO $ newMVar ()
|
||||
--
|
||||
-- This function is thread-safe.
|
||||
isCustomTableReady :: IO Bool
|
||||
isCustomTableReady =
|
||||
E.bracket takeInstallLock (const releaseInstallLock) $
|
||||
const $ (== 1) <$> c_isCustomTableReady
|
||||
isCustomTableReady = withInstallLock $ (== 1) <$> c_isCustomTableReady
|
||||
|
||||
withInstallLock :: IO a -> IO a
|
||||
withInstallLock act =
|
||||
E.bracket takeInstallLock (const releaseInstallLock) $ const act
|
||||
|
||||
takeInstallLock :: IO ()
|
||||
takeInstallLock = takeMVar installLock
|
||||
@ -96,8 +98,7 @@ instance E.Exception TableInstallException
|
||||
--
|
||||
-- This function is thread-safe.
|
||||
installUnicodeWidthTable :: UnicodeWidthTable -> IO ()
|
||||
installUnicodeWidthTable table =
|
||||
E.bracket takeInstallLock (const releaseInstallLock) $ const $ do
|
||||
installUnicodeWidthTable table = withInstallLock $ do
|
||||
initResult <- initCustomTable tableSize
|
||||
when (initResult /= 0) $
|
||||
E.throw $ TableInitFailure initResult tableSize
|
||||
|
Loading…
Reference in New Issue
Block a user