Struct cacao::foundation::AutoReleasePool
source · [−]Expand description
A wrapper around NSAutoReleasePool
. The core App
structures create and manage one of these,
but it’s conceivable that users might need to create their own.
When this is dropped, we automatically send a drain
message to the underlying pool. You can
also call drain()
yourself if you need to drain for whatever reason.
Tuple Fields
0: Id<Object>
Implementations
sourceimpl AutoReleasePool
impl AutoReleasePool
sourcepub fn new() -> Self
pub fn new() -> Self
Creates and returns a new AutoReleasePool
. You need to take care to keep this alive for
as long as you need it.
sourcepub fn run<F>(handler: F) where
F: Fn() + 'static,
pub fn run<F>(handler: F) where
F: Fn() + 'static,
Run a function with a one-off AutoReleasePool.
This will create a custom NSAutoreleasePool, run your handler, and automatically drain
when done. This is (roughly, ish) equivalent to @autoreleasepool {}
under ARC. If you
need to perform Cocoa calls on a different thread, it’s important to ensure they’re backed
with an autorelease pool - otherwise your memory footprint will continue to grow.
Trait Implementations
sourceimpl Debug for AutoReleasePool
impl Debug for AutoReleasePool
sourceimpl Drop for AutoReleasePool
impl Drop for AutoReleasePool
Auto Trait Implementations
impl RefUnwindSafe for AutoReleasePool
impl Send for AutoReleasePool
impl Sync for AutoReleasePool
impl Unpin for AutoReleasePool
impl UnwindSafe for AutoReleasePool
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more