avoid building up a lot of threads all waiting for their chance to run a push

Only 2 threads are needed, one running, and one waiting to push something
new. Any more is redundant and wasteful.
This commit is contained in:
Joey Hess 2013-05-22 00:27:12 -04:00
parent 6e04194e84
commit cc68b340ff
2 changed files with 59 additions and 18 deletions

View file

@ -133,6 +133,9 @@ data NetMessager = NetMessager
-- only one side of a push can be running at a time
-- the TMVars are empty when nothing is running
, netMessagerPushRunning :: SideMap (TMVar ClientID)
-- number of threads trying to push to the same client
-- at the same time (either running, or waiting to run)
, netMessagerPushThreadCount :: SideMap (TVar (M.Map ClientID Int))
-- incoming messages containing data for a push,
-- on a per-client and per-side basis
, netMessagesInboxes :: SideMap Inboxes
@ -146,3 +149,4 @@ newNetMessager = NetMessager
<*> newEmptySV
<*> mkSideMap newEmptyTMVar
<*> mkSideMap (newTVar M.empty)
<*> mkSideMap (newTVar M.empty)