Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tobias Decking
GHC
Commits
8a9a56e2
Commit
8a9a56e2
authored
Feb 02, 1999
by
simonm
Browse files
[project @ 1999-02-02 14:40:46 by simonm]
Mention 'finalise' and 'mkWeakNoFinaliser'.
parent
bf739c10
Changes
1
Hide whitespace changes
Inline
Side-by-side
ghc/docs/libraries/Weak.sgml
View file @
8a9a56e2
...
...
@@ -19,15 +19,16 @@ module Weak (
-- instance Eq (Weak v)
mkWeak, -- :: k -> v -> IO () -> IO (Weak v)
deRefWeak -- :: Weak v -> IO (Maybe v)
deRefWeak, -- :: Weak v -> IO (Maybe v)
finalise, -- :: Weak v -> IO ()
-- Not yet implemented
-- finalise -- :: Weak v -> IO ()
-- replaceFinaliser -- :: Weak v -> IO () -> IO ()
mkWeakPtr -- :: k -> IO () -> IO (Weak k)
mkWeakPair -- :: k -> v -> IO () -> IO (Weak (k,v))
addFinaliser -- :: k -> IO () -> IO ()
mkWeakPtr, -- :: k -> IO () -> IO (Weak k)
mkWeakPair, -- :: k -> v -> IO () -> IO (Weak (k,v))
mkWeakNoFinaliser, -- :: k -> v -> IO (Weak v)
addFinaliser, -- :: k -> IO () -> IO ()
addForeignFinaliser -- :: ForeignObj -> IO () -> IO ()
) where
</verb></tscreen>
...
...
@@ -188,6 +189,26 @@ weak pointers:
These more general weak pointers are enough to implement memo
tables properly.
A weak pointer can be finalised early, using the <tt/finalise/ operation:
<tscreen><verb>
finalise :: Weak v -> IO ()
</verb></tscreen>
When you don't need a finaliser, we provide the following operation:
<tscreen><verb>
mkWeakNoFinaliser :: k -> v -> IO (Weak v)
mkWeakNoFinaliser k v = mkWeak k v (return ())
</verb></tscreen>
Which creates a weak pointer with a null finaliser. Lots of null
finalisers can be expensive, because each one runs in a separate
thread, so the intention is that <tt/mkWeakNoFinaliser> avoids all the
extra costs by generating a special kind of weak pointer without a
finaliser. So although the semantics of mkWeakNoFinaliser is as given
above, its actual implementation is somewhat different.
<sect1> A precise semantics
<p>
The above informal specification is fine for simple situations,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment