vulkan-utils-0.5.11.0: Utils for the vulkan package
Safe HaskellNone
LanguageHaskell2010

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

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