Post

Spending my evening with a Rust project figuring out a Drop implementation on a ConnectionPool that can do a best-effort cleanup of active connections. If the caller forgets to do an explicit call to the close method, I'd like it to be as low-impact as possible. This is hard stuff. But fun!

0 reposts1 like

Well, Drop can't be async, so you can't await on the shutdown of whatever you're pooling unless you block, but you can spawn cleanup tasks. Which means managing race conditions and ensuring fairness. I could also *not* do this and just mark with Drop and sweep with an explicit close() call. But hey.