On Sat, Jul 4, 2015 at 8:35 AM, Svante v. Erichsen Svante.v.Erichsen@web.de wrote:
Hi!
On 2015-07-04 19:30:01+0800, Elias Mårtenson wrote:
My question is: Should I use trivial-garbage to create a GC hook for the connection object so that if the user of the library forgets to close the connection, it will get closed eventually once it's GC'ed?
My first impulse is to say “that is what garbage collection is there for”. It needs not matter whether the object resides in C or Lisp land or what kind of resource it is; if the system can identify that it is garbage, it should collect it.
The alternative would also mean that it is difficult for the system to recover from the mistake without restart.
Additionally, the API might benefit from a with-async-connection and a with-open-channel macro.
It might be a good idea to have a GC hook, but you might want your GC hook to log and/or count dropped connections, so you can later detect and fix the underlying issues. Belt and suspenders.
—♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org It's not "privilege". It's *capital*. It's not forcefully taken away from others in a negative sum game. It's created, preserved and transmitted in a positive sum game.