| Maintainer | Bas van Dijk <v.dijk.bas@gmail.com> |
|---|
Foreign.Ptr.Region
Description
- data RegionalPtr α r
- nullPtr :: RegionalPtr α RootRegion
- module Control.Monad.Trans.Region
- mapRegionalPtr :: (Ptr α -> Ptr β) -> RegionalPtr α r -> RegionalPtr β r
- castPtr :: RegionalPtr α r -> RegionalPtr β r
- plusPtr :: RegionalPtr α r -> Int -> RegionalPtr β r
- alignPtr :: RegionalPtr α r -> Int -> RegionalPtr α r
- minusPtr :: RegionalPtr α r1 -> RegionalPtr β r2 -> Int
Regional pointers
data RegionalPtr α r Source
A regional handle to memory. This should provide a safer replacement for
Foreign.Ptr.
Ptr
Instances
| Dup (RegionalPtr α) |
nullPtr :: RegionalPtr α RootRegionSource
The constant nullPtr contains a distinguished value of RegionalPtr
that is not associated with a valid memory location.
Note that nullPtr is a pure value. This means it does not perform the
side-effect of registering a finalizer like free nullPtr
in the RegionT monad.
Finally note that the region parameter of the RegionalPtr is set to
RootRegion which is the ancestor of any region. This allows nullPtr to be
used in any region.
Note that this module re-exports the Control.Monad.Trans.Region
module from the regions package which allows you to:
- Run a region using
runRegionT. - Concurrently run a region inside another region using
forkIOTopRegion. - Duplicate a
RegionalPtrto a parent region usingdup.
module Control.Monad.Trans.Region
Pure functions on regional pointers
mapRegionalPtr :: (Ptr α -> Ptr β) -> RegionalPtr α r -> RegionalPtr β rSource
Apply a pure function to the inner pointer of a regional pointer.
castPtr :: RegionalPtr α r -> RegionalPtr β rSource
The castPtr function casts a pointer from one type to another.
Wraps: Foreign.Ptr.castPtr
plusPtr :: RegionalPtr α r -> Int -> RegionalPtr β rSource
Advances the given address by the given offset in bytes.
Wraps: Foreign.Ptr.plusPtr
alignPtr :: RegionalPtr α r -> Int -> RegionalPtr α rSource
Given an arbitrary address and an alignment constraint, alignPtr yields
the next higher address that fulfills the alignment constraint. An alignment
constraint x is fulfilled by any address divisible by x. This operation
is idempotent.
Wraps: Foreign.Ptr.alignPtr
minusPtr :: RegionalPtr α r1 -> RegionalPtr β r2 -> IntSource
Computes the offset required to get from the second to the first argument. We have
p2 == p1 `plusPtr` (p2 `minusPtr` p1)
Wraps: Foreign.Ptr.minusPtr