mirror of
https://github.com/awkward-squad/ki.git
synced 2024-10-03 22:57:51 +03:00
move ThreadAffinity into its own module
This commit is contained in:
parent
30d26f47ac
commit
cc554dd7dc
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
.envrc
|
||||
.ghc.environment.*
|
||||
.ghcid
|
||||
Session.vim
|
||||
dist-newstyle/
|
||||
|
@ -93,6 +93,7 @@ library
|
||||
Ki.Internal.NonblockingSTM
|
||||
Ki.Internal.Scope
|
||||
Ki.Internal.Thread
|
||||
Ki.Internal.ThreadAffinity
|
||||
|
||||
test-suite tests
|
||||
import: component
|
||||
|
@ -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
|
||||
|
14
ki/src/Ki/Internal/ThreadAffinity.hs
Normal file
14
ki/src/Ki/Internal/ThreadAffinity.hs
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user