-
Notifications
You must be signed in to change notification settings - Fork 202
Open
Description
Most functions end up using native apis which create autorelease objects.
These objects would be effectively "leaked" if run through async++.
The thread pool/loop needs local per-iteration pool to match user expectations(or lack of).
sample Qt pool handling:
#ifdef __APPLE__
// Use the direct runtime interface to manage autorelease pools, as it
// has less overhead then allocating NSAutoreleasePools, and allows for
// a future where we use ARC (where NSAutoreleasePool is not allowed).
// https://clang.llvm.org/docs/AutomaticReferenceCounting.html#runtime-support
extern "C" {
void *objc_autoreleasePoolPush(void);
void objc_autoreleasePoolPop(void *pool);
}
#define AUTORELEASE_THREAD_GUARD() auto poolDone = ScopedDefer([pool = objc_autoreleasePoolPush()](){ objc_autoreleasePoolPop(pool); });
#else
#define AUTORELEASE_THREAD_GUARD()
#endif
Metadata
Metadata
Assignees
Labels
No labels