-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move ThreadOptions into its own module
- Loading branch information
1 parent
0b1be3d
commit bb0115d
Showing
5 changed files
with
80 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
module Ki.Internal.ThreadOptions | ||
( ThreadOptions (..), | ||
defaultThreadOptions, | ||
) | ||
where | ||
|
||
import Control.Exception (MaskingState (..)) | ||
import Ki.Internal.ByteCount (ByteCount) | ||
import Ki.Internal.ThreadAffinity (ThreadAffinity (..)) | ||
|
||
-- | | ||
-- | ||
-- [@affinity@]: | ||
-- | ||
-- The affinity of a thread. A thread can be unbound, bound to a specific capability, or bound to a specific OS | ||
-- thread. | ||
-- | ||
-- Default: 'Unbound' | ||
-- | ||
-- [@allocationLimit@]: | ||
-- | ||
-- The maximum number of bytes a thread may allocate before it is delivered an | ||
-- 'Control.Exception.AllocationLimitExceeded' exception. If caught, the thread is allowed to allocate an additional | ||
-- 100kb (tunable with @+RTS -xq@) to perform any necessary cleanup actions; if exceeded, the thread is delivered | ||
-- another. | ||
-- | ||
-- Default: @Nothing@ (no limit) | ||
-- | ||
-- [@label@]: | ||
-- | ||
-- The label of a thread, visible in the [event log](https://downloads.haskell.org/ghc/latest/docs/html/users_guide/runtime_control.html#rts-eventlog) (@+RTS -l@). | ||
-- | ||
-- Default: @""@ (no label) | ||
-- | ||
-- [@maskingState@]: | ||
-- | ||
-- The masking state a thread is created in. To unmask, use 'GHC.IO.unsafeUnmask'. | ||
-- | ||
-- Default: @Unmasked@ | ||
data ThreadOptions = ThreadOptions | ||
{ affinity :: ThreadAffinity, | ||
allocationLimit :: Maybe ByteCount, | ||
label :: String, | ||
maskingState :: MaskingState | ||
} | ||
deriving stock (Eq, Show) | ||
|
||
-- | Default thread options. | ||
-- | ||
-- @ | ||
-- 'Ki.ThreadOptions' | ||
-- { 'Ki.affinity' = 'Ki.Unbound' | ||
-- , 'Ki.allocationLimit' = Nothing | ||
-- , 'Ki.label' = "" | ||
-- , 'Ki.maskingState' = 'Unmasked' | ||
-- } | ||
-- @ | ||
defaultThreadOptions :: ThreadOptions | ||
defaultThreadOptions = | ||
ThreadOptions | ||
{ affinity = Unbound, | ||
allocationLimit = Nothing, | ||
label = "", | ||
maskingState = Unmasked | ||
} |