[Git][ghc/ghc][wip/T22706] base: Export GHC.Conc.Sync.fromThreadId

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Fri Mar 24 12:29:49 UTC 2023



Ben Gamari pushed to branch wip/T22706 at Glasgow Haskell Compiler / GHC


Commits:
b9c348b9 by Ben Gamari at 2023-03-24T08:29:42-04:00
base: Export GHC.Conc.Sync.fromThreadId

Closes #22706.

- - - - -


2 changed files:

- libraries/base/GHC/Conc/Sync.hs
- libraries/base/changelog.md


Changes:

=====================================
libraries/base/GHC/Conc/Sync.hs
=====================================
@@ -33,6 +33,7 @@ module GHC.Conc.Sync
         (
         -- * Threads
           ThreadId(..)
+        , fromThreadId
         , showThreadId
         , myThreadId
         , killThread
@@ -152,11 +153,18 @@ This misfeature will hopefully be corrected at a later date.
 
 -}
 
+-- | Map a thread to an integer identifier which is unique within the
+-- current process.
+--
+-- @since 4.19.0.0
+fromThreadId :: ThreadId -> Word64
+fromThreadId = fromIntegral . getThreadId . id2TSO
+
 -- | @since 4.2.0.0
 instance Show ThreadId where
    showsPrec d t = showParen (d >= 11) $
         showString "ThreadId " .
-        showsPrec d (getThreadId (id2TSO t))
+        showsPrec d (fromThreadId t)
 
 showThreadId :: ThreadId -> String
 showThreadId = show


=====================================
libraries/base/changelog.md
=====================================
@@ -1,6 +1,8 @@
 # Changelog for [`base` package](http://hackage.haskell.org/package/base)
 
 ## 4.19.0.0 *TBA*
+
+  * `GHC.Conc.Sync` now exports `fromThreadId :: ThreadId -> Word64`, which maps a thread to a per-process-unique identifier ([CLC proposal #117](https://github.com/haskell/core-libraries-committee/issues/117))
   * Add `Data.List.!?` ([CLC proposal #110](https://github.com/haskell/core-libraries-committee/issues/110))
   * `maximumBy`/`minimumBy` are now marked as `INLINE` improving performance for unpackable
     types significantly.



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b9c348b964b4f26180a1a6262db71cc06af00801

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b9c348b964b4f26180a1a6262db71cc06af00801
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230324/4e98593a/attachment-0001.html>


More information about the ghc-commits mailing list