modulePrioritySync.Internal.RoomConstraint(RoomConstraint(..),MaxThreads(..),approveClaims)whereimportPrioritySync.Internal.RoomCoreimportControl.Concurrent.STMimportControl.MonadimportData.SetasSetclassRoomConstraintuwhere-- | Should either 'approve' or 'retry' each claim.approveConstraint::Claima->u->STM()instanceRoomConstraint()whereapproveConstraintc()=approvecinstanceRoomConstraintBoolwhere-- this is pointless but means we support RoomConstraint (STM Bool)approveConstraintcTrue=approvecapproveConstraint_False=retry-- | A maximum limit on the number of threads allowed to claim a room.newtypeMaxThreads=MaxThreadsIntinstanceRoomConstraintMaxThreadswhereapproveConstraintc(MaxThreadsn)=dos<-liftM(Set.size.Set.insert(claimedThreadc))$inUse$claimedRoomcapproveConstraintc$s<=ninstance(RoomConstraintu)=>RoomConstraint(STMu)whereapproveConstraintcactionSTM=approveConstraintc=<<actionSTMinstance(RoomConstrainta,RoomConstraintb)=>RoomConstraint(a,b)whereapproveConstraintc(a,b)=doapproveConstraintcaapproveConstraintcbinstance(RoomConstrainta,RoomConstraintb)=>RoomConstraint(Eitherab)whereapproveConstraintc=either(approveConstraintc)(approveConstraintc)instance(RoomConstrainta)=>RoomConstraint(Maybea)whereapproveConstraintc=maybe(approveConstraintc())$approveConstraintc-- | 'approve' some claims according to their constraints.approveClaims::(RoomConstraintu)=>[Claimu]->STM()approveClaims=mapM_(\c->approveConstraintc$userData$claimedRoomc)