Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gesh
GHC
Commits
d31ac01c
Commit
d31ac01c
authored
26 years ago
by
Simon Marlow
Browse files
Options
Downloads
Patches
Plain Diff
[project @ 1999-02-02 14:19:02 by simonm]
- Add Weak.finalise - Move some functions from PrelWeak to Weak.
parent
011886e4
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ghc/lib/exts/Weak.lhs
+24
-4
24 additions, 4 deletions
ghc/lib/exts/Weak.lhs
ghc/lib/std/PrelWeak.lhs
+0
-19
0 additions, 19 deletions
ghc/lib/std/PrelWeak.lhs
with
24 additions
and
23 deletions
ghc/lib/exts/Weak.lhs
+
24
−
4
View file @
d31ac01c
...
...
@@ -2,18 +2,16 @@
% (c) The AQUA Project, Glasgow University, 1998
%
\section[Weak]{Module @
Prel
Weak@}
\section[Weak]{Module @Weak@}
\begin{code}
{-# OPTIONS -fno-implicit-prelude #-}
module Weak (
Weak, -- abstract
-- instance Eq (Weak v)
mkWeak, -- :: k -> v -> IO () -> IO (Weak v)
deRefWeak, -- :: Weak v -> IO (Maybe v)
--
finalise -- :: Weak v -> IO ()
finalise
,
-- :: Weak v -> IO ()
-- replaceFinaliser -- :: Weak v -> IO () -> IO ()
mkWeakNoFinaliser, -- :: k -> v -> IO (Weak v)
...
...
@@ -23,6 +21,28 @@ module Weak (
addForeignFinaliser -- :: ForeignObj -> IO () -> IO ()
) where
import PrelBase
import PrelIOBase
import PrelWeak
import Foreign
deRefWeak :: Weak v -> IO (Maybe v)
deRefWeak (Weak w) = IO $ \s ->
case deRefWeak# w s of
(# s1, flag, p #) -> case flag of
0# -> (# s1, Nothing #)
_ -> (# s1, Just p #)
mkWeakNoFinaliser key val = IO $ \s ->
-- zero is a valid finaliser argument to mkWeak#, and means "no finaliser"
case mkWeak# key val (unsafeCoerce# 0#) s of { (# s1, w #) ->
(# s1, Weak w #) }
mkWeakPair :: k -> v -> IO () -> IO (Weak (k,v))
mkWeakPair key val finaliser = mkWeak key (key,val) finaliser
finalise :: Weak v -> IO ()
finalise (Weak w) = IO $ \s ->
case finaliseWeak# w s of s1 -> (# s1, () #)
\end{code}
This diff is collapsed.
Click to expand it.
ghc/lib/std/PrelWeak.lhs
+
0
−
19
View file @
d31ac01c
...
...
@@ -10,7 +10,6 @@
module PrelWeak where
import PrelGHC
import PrelMaybe
import PrelBase
import PrelIOBase
import PrelForeign
...
...
@@ -26,24 +25,9 @@ mkWeak key val finaliser = IO $ \s ->
case mkWeak# key val finaliser s of { (# s1, w #) ->
(# s1, Weak w #) }
mkWeakNoFinaliser key val = IO $ \s ->
-- zero is a valid finaliser argument to mkWeak#, and means "no finaliser"
case mkWeak# key val (unsafeCoerce# 0#) s of { (# s1, w #) ->
(# s1, Weak w #) }
deRefWeak :: Weak v -> IO (Maybe v)
deRefWeak (Weak w) = IO $ \s ->
case deRefWeak# w s of
(# s1, flag, p #) -> case flag of
0# -> (# s1, Nothing #)
_ -> (# s1, Just p #)
mkWeakPtr :: k -> IO () -> IO (Weak k)
mkWeakPtr key finaliser = mkWeak key key finaliser
mkWeakPair :: k -> v -> IO () -> IO (Weak (k,v))
mkWeakPair key val finaliser = mkWeak key (key,val) finaliser
addFinaliser :: key -> IO () -> IO ()
addFinaliser key finaliser = do
mkWeakPtr key finaliser -- throw it away
...
...
@@ -53,9 +37,6 @@ addForeignFinaliser :: ForeignObj -> IO () -> IO ()
addForeignFinaliser (ForeignObj fo) finaliser = addFinaliser fo finaliser
{-
finalise :: Weak v -> IO ()
finalise (Weak w) = finaliseWeak# w
instance Eq (Weak v) where
(Weak w1) == (Weak w2) = w1 `sameWeak#` w2
-}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment