Safe Haskell | None |
---|---|
Language | Haskell98 |
Synopsis
- data FastWeakTicket a
- type FastWeak a = Weak a
- mkFastWeakTicket :: a -> IO (FastWeakTicket a)
- getFastWeakTicketValue :: FastWeakTicket a -> IO a
- getFastWeakTicketWeak :: FastWeakTicket a -> IO (FastWeak a)
- getFastWeakValue :: FastWeak a -> IO (Maybe a)
- getFastWeakTicket :: forall a. FastWeak a -> IO (Maybe (FastWeakTicket a))
- emptyFastWeak :: FastWeak a
Documentation
data FastWeakTicket a Source #
A FastWeak
which has been promoted to a strong reference. getFastWeakTicketValue
can be used to get the referred to value without fear of Nothing
,
and getFastWeakTicketWeak
can be used to get the weak version.
type FastWeak a = Weak a Source #
A reference to some value which can be garbage collected if there are only weak references to the value left.
getFastWeakValue
can be used to try and obtain a strong reference to the value.
The value in a FastWeak
can also be kept alive by obtaining a FastWeakTicket
using getFastWeakTicket
if the value hasn't been collected yet.
Synonymous with Weak
.
mkFastWeakTicket :: a -> IO (FastWeakTicket a) Source #
Create a FastWeakTicket
directly from a value, creating a FastWeak
in the process
which can be obtained with getFastWeakTicketValue
.
getFastWeakTicketValue :: FastWeakTicket a -> IO a Source #
Return the a
kept alive by the given FastWeakTicket
.
This needs to be in IO so we know that we've relinquished the ticket.
getFastWeakTicketWeak :: FastWeakTicket a -> IO (FastWeak a) Source #
Demote a FastWeakTicket
; which ensures the value is alive, to a FastWeak
which doesn't.
Note that unless the ticket for the same FastWeak
is held in some other way
the value might be collected immediately.
getFastWeakValue :: FastWeak a -> IO (Maybe a) Source #
Get the value referred to by a FastWeak
if it hasn't yet been collected,
or Nothing
if it has been collected.
getFastWeakTicket :: forall a. FastWeak a -> IO (Maybe (FastWeakTicket a)) Source #
Try to create a FastWeakTicket
for the given FastWeak
which will ensure the value referred
remains alive. Returns Just
if the value hasn't been collected
and a ticket can therefore be obtained, Nothing
if it's been collected.
emptyFastWeak :: FastWeak a Source #
A weak reference that is always empty