| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Vulkan.Utils.RefCounted
Description
Lightweight reference counter that runs a release action when the count hits zero. Useful for keeping a Vulkan object alive across an unknown number of in-flight frames — bump the count when a frame starts using it, drop the count when the frame retires, and the object is destroyed promptly after the last frame finishes.
Synopsis
- data RefCounted
- newRefCounted :: MonadIO m => IO () -> m RefCounted
- releaseRefCounted :: MonadIO m => RefCounted -> m ()
- takeRefCounted :: MonadIO m => RefCounted -> m ()
- resourceTRefCount :: MonadResource f => RefCounted -> f ()
Documentation
data RefCounted Source #
A RefCounted will perform the specified action when the count reaches 0
newRefCounted :: MonadIO m => IO () -> m RefCounted Source #
Create a counter with a value of 1
releaseRefCounted :: MonadIO m => RefCounted -> m () Source #
Decrement the value, the action will be run promptly and in this thread if the counter reached 0.
takeRefCounted :: MonadIO m => RefCounted -> m () Source #
Increment the counter by 1
resourceTRefCount :: MonadResource f => RefCounted -> f () Source #
Hold a reference for the duration of the MonadResource action