diff --git a/.gitignore b/.gitignore index fb87c15..f4991b8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .envrc .ghc.environment.* .ghcid +Session.vim dist-newstyle/ diff --git a/ki/ki.cabal b/ki/ki.cabal index 2ed6cd1..9339db8 100644 --- a/ki/ki.cabal +++ b/ki/ki.cabal @@ -93,6 +93,7 @@ library Ki.Internal.NonblockingSTM Ki.Internal.Scope Ki.Internal.Thread + Ki.Internal.ThreadAffinity test-suite tests import: component diff --git a/ki/src/Ki/Internal/Thread.hs b/ki/src/Ki/Internal/Thread.hs index 7b4b5fd..4d82eb0 100644 --- a/ki/src/Ki/Internal/Thread.hs +++ b/ki/src/Ki/Internal/Thread.hs @@ -22,8 +22,9 @@ import Control.Exception asyncExceptionToException, ) import GHC.Conc (STM) -import Ki.Internal.ByteCount +import Ki.Internal.ByteCount (ByteCount) import Ki.Internal.IO (forkIO, forkOn, tryEitherSTM) +import Ki.Internal.ThreadAffinity (ThreadAffinity (..)) -- | A thread. -- @@ -65,16 +66,6 @@ makeThread threadId action = type Tid = Int --- | What, if anything, a thread is bound to. -data ThreadAffinity - = -- | Unbound. - Unbound - | -- | Bound to a capability. - Capability Int - | -- | Bound to an OS thread. - OsThread - deriving stock (Eq, Show) - -- forkIO/forkOn/forkOS, switching on affinity forkWithAffinity :: ThreadAffinity -> IO () -> IO ThreadId forkWithAffinity = \case diff --git a/ki/src/Ki/Internal/ThreadAffinity.hs b/ki/src/Ki/Internal/ThreadAffinity.hs new file mode 100644 index 0000000..fb0e19e --- /dev/null +++ b/ki/src/Ki/Internal/ThreadAffinity.hs @@ -0,0 +1,14 @@ +module Ki.Internal.ThreadAffinity + ( ThreadAffinity (..), + ) +where + +-- | What, if anything, a thread is bound to. +data ThreadAffinity + = -- | Unbound. + Unbound + | -- | Bound to a capability. + Capability Int + | -- | Bound to an OS thread. + OsThread + deriving stock (Eq, Show)