I modified Framebuffer to support caching mechanism under ARC(Automatic Reference Counting) by using hidden core framebuffer class (Framebuffer.Core in Framebuffer.swift).
The way this works is that FramebufferCache caches only the Framebuffer.Core object and returns the wrapped Framebuffer object.
Framebuffer object has deinit() methods that returns the internal Framebuffer.Core object to cache if it exists. This way the framebuffer is safely returned to the cache when it is not referenced without worrying about locking/unlocking.
Framebuffer class redirects all the methods and variable properties to the internal Framebuffer.Core object and has same constant properties with it.
lock(), unlock(), resetRetainCount(), framebufferRetainCount are removed accordingly.
I modified
Framebuffer
to support caching mechanism under ARC(Automatic Reference Counting) by using hidden core framebuffer class (Framebuffer.Core
in Framebuffer.swift).The way this works is that
FramebufferCache
caches only theFramebuffer.Core
object and returns the wrappedFramebuffer
object.Framebuffer
object hasdeinit()
methods that returns the internalFramebuffer.Core
object to cache if it exists. This way the framebuffer is safely returned to the cache when it is not referenced without worrying about locking/unlocking.Framebuffer
class redirects all the methods and variable properties to the internalFramebuffer.Core
object and has same constant properties with it.lock()
,unlock()
,resetRetainCount()
,framebufferRetainCount
are removed accordingly.