use TMap for subscription maps (#341)

* use TMap for subscription maps

* refactor

* correction
This commit is contained in:
Evgeny Poberezkin
2022-03-28 18:49:17 +01:00
committed by GitHub
parent 6ef6bedc03
commit cd22e06b3a
4 changed files with 76 additions and 60 deletions
+3 -3
View File
@@ -114,9 +114,9 @@ newEnv config@ServerConfig {caCertificateFile, certificateFile, privateKeyFile}
restoreQueues QueueStore {queues, senders, notifiers} s = do
(qs, s') <- liftIO $ readWriteStoreLog s
atomically $ do
writeTVar (TM.tVar queues) =<< mapM newTVar qs
writeTVar (TM.tVar senders) $ M.foldr' addSender M.empty qs
writeTVar (TM.tVar notifiers) $ M.foldr' addNotifier M.empty qs
writeTVar queues =<< mapM newTVar qs
writeTVar senders $ M.foldr' addSender M.empty qs
writeTVar notifiers $ M.foldr' addNotifier M.empty qs
pure s'
addSender :: QueueRec -> Map SenderId RecipientId -> Map SenderId RecipientId
addSender q = M.insert (senderId q) (recipientId q)