On Wed, Jun 23, 2010 at 7:23 PM, Stuart Halloway <s...@thinkrelevance.com> wrote: > If the context represents any real resources on the native side, I would > recommend going in the opposite direction: > > (1) Clients should create and hold the context, and explicitly close it when > they are done. > > (2) Ditto for sockets (except that creation is via the context). > > (3) Neither Context nor Socket should implement finalize. > > (4) Instead, they should implement the Closeable interface [1]. > > How costly is the context? Should it be created once per process? Once per > thread? Something else? > > [1] http://java.sun.com/j2se/1.5.0/docs/api/java/io/Closeable.html >
I can't speak to how expensive these resources are (or could be in the future), but will add +1 for these suggestions. I had a similar thought back when I was working with the 2.0.5+ version of the API, but the Java binding underwent a hefty design phase to make it look/feel more like some of the other language bindings. Now that you've brought it up again, it makes me wonder if there ought to be a general guideline in the binding developer guidelines [1] to implement support for a given language's "resource closing" interface (whatever analogy exists in the given language). For example, Java has java.io.Closeable, Python has the "context management protocol" for use in "with" statements, etc. [1] http://www.zeromq.org/guidelines:bindings _______________________________________________ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev