sdl2-compositor-1.2.0.7: image compositing with sdl2 - declarative style

Safe HaskellNone
LanguageHaskell2010

SDL.Data.Cache

Description

This module provides a simple caching implementation based on the LRU caching strategy. The cache is implemented via software transactional memory, which means that you can use the cache from different threads.

Synopsis

Documentation

class Cacheable r where #

Something is cacheable if there is an action to release the resource (if necessary).

Minimal complete definition

releaseResource

Methods

releaseResource :: r -> IO () #

Instances

Cacheable Int # 

Methods

releaseResource :: Int -> IO () #

Cacheable Surface # 

Methods

releaseResource :: Surface -> IO () #

Cacheable Texture # 

Methods

releaseResource :: Texture -> IO () #

Cacheable RawTexture # 

Methods

releaseResource :: RawTexture -> IO () #

Cacheable a => Cacheable [a] # 

Methods

releaseResource :: [a] -> IO () #

Cacheable a => Cacheable (Maybe a) # 

Methods

releaseResource :: Maybe a -> IO () #

data Cache k a #

Thread safe LRU cache.

newCache #

Arguments

:: Ord k 
=> Int

the size of the cache to be created (in elements)

-> IO (Cache k a) 

Create a new cache instance.

throughCache #

Arguments

:: (Cacheable r, Ord k) 
=> Cache k r

cache instance

-> k

cache key

-> IO r

action to generate the resource

-> IO r 

Check if a certain element is already cached. If not execute the action the generate this element.

emptyCache :: (Cacheable r, Ord k) => Cache k r -> IO () #

Invalidate every element in the cache and release the resources accordingly.