3 ms·
> This third one makes using longjmp for exceptions almost untenable in real life code. No, it's pretty simple. Postgres does it with something called regions:
by adgar 15y ago
> This third one makes using longjmp for exceptions almost untenable in real life code.
No, it's pretty simple. Postgres does it with something called regions: your code essentially becomes transaction-based, where resources that need cleanup are put into a region associated with a try block, and all remaining resources at the end of the block's (successful or failed) execution are freed. It requires slightly more work than in C++, obviously, because you're not using C++.
- rwmj 15y agoThis is nice. It's pretty much how the pool allocator "integration" works. I say integration in quotes because with the pool allocator you (also) have to be careful at the try site that any pools or subpools used in the code that could throw will be freed.