{-# LANGUAGE DeriveGeneric         #-}
{-# LANGUAGE DuplicateRecordFields #-}

module HaskellWorks.CabalCache.Concurrent.Type
  ( DownloadQueue(..)
  , ConsumerId
  , ProviderId
  , PackageId
  ) where

import GHC.Generics
import HaskellWorks.CabalCache.Types (PackageId)

import qualified Control.Concurrent.STM as STM
import qualified Data.Relation          as R
import qualified Data.Set               as S

type ConsumerId = PackageId
type ProviderId = PackageId

data DownloadQueue = DownloadQueue
  { DownloadQueue -> TVar (Relation ConsumerId ConsumerId)
tDependencies :: STM.TVar (R.Relation ConsumerId ProviderId)
  , DownloadQueue -> TVar (Set ConsumerId)
tUploading    :: STM.TVar (S.Set PackageId)
  , DownloadQueue -> TVar (Set ConsumerId)
tFailures     :: STM.TVar (S.Set PackageId)
  } deriving (forall x. DownloadQueue -> Rep DownloadQueue x)
-> (forall x. Rep DownloadQueue x -> DownloadQueue)
-> Generic DownloadQueue
forall x. Rep DownloadQueue x -> DownloadQueue
forall x. DownloadQueue -> Rep DownloadQueue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DownloadQueue x -> DownloadQueue
$cfrom :: forall x. DownloadQueue -> Rep DownloadQueue x
Generic