Description
I'm using this pattern a lot in ffigen tests:
final pool = lib.objc_autoreleasePoolPush();
// Do stuff ...
lib.objc_autoreleasePoolPop(pool);
Should we expose this capability in package:objective_c? It might be useful to some users, but it's a bit problematic.
In a language like C++ we could make a util class that calls push in the constructor and pop in the destructor, and users could declare a local variable of this class to turn their scope into an autorelease pool.
But in Dart if we did that using finalizers, pop would be called at an undefined time in the future. Worse, this could mean pools are popped out of order (popping an outer pool pops all the inner pools, so later when the inner pool is popped we'd be double popping, which is not allowed).
So our only option would be to expose push and pop directly as standalone functions, which is a bit of a footgun.
Metadata
Metadata
Assignees
Type
Projects
Status