aboutsummaryrefslogtreecommitdiff
path: root/Assistant/Types/TransferSlots.hs
blob: 5fa1219a7fb8b41bea7fe367e7f649117a0f8da8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{- git-annex assistant transfer slots
 -
 - Copyright 2012 Joey Hess <id@joeyh.name>
 -
 - Licensed under the GNU GPL version 3 or higher.
 -}

{-# LANGUAGE DeriveDataTypeable #-}

module Assistant.Types.TransferSlots where

import qualified Control.Exception as E
import qualified Control.Concurrent.MSemN as MSemN
import Data.Typeable

type TransferSlots = MSemN.MSemN Int

{- A special exception that can be thrown to pause or resume a transfer, while
 - keeping its slot in use. -}
data TransferException = PauseTransfer | ResumeTransfer
	deriving (Show, Eq, Typeable)

instance E.Exception TransferException

{- Number of concurrent transfers allowed to be run from the assistant.
 -
 - Transfers launched by other means, including by remote assistants,
 - do not currently take up slots.
 -}
numSlots :: Int
numSlots = 1

newTransferSlots :: IO TransferSlots
newTransferSlots = MSemN.new numSlots