[Mulgara-general] Connections thread safe?

Paul Gearon gearon at ieee.org
Tue Feb 26 21:16:38 UTC 2008


On Tue, Feb 26, 2008 at 1:32 PM, Alex Hall <alexhall at revelytix.com> wrote:
> Are Connections in Mulgara thread-safe?  I am writing an abstraction
>  layer on top of Mulgara to represent ontology models, and each "model"
>  needs to have a Connection to the server that it uses to execute queries
>  to get ontology metadata, list classes, etc.
>
>  Since the ConnectionFactory caches the Connections that it creates, if
>  the models all share the same factory then they will wind up using the
>  same Connection object.  This could possibly result in multiple,
>  overlapping commands being executed on the same session from different
>  threads.  Is this OK, or should I ensure that each model gets its own
>  Connection instance?

The plan was to use one factory per thread.  However, now that you
raise it, it sounds like a bad idea.  I should probably put in some
TLS so that a shared factory will hand out new Connections for new
threads.

This is all working on the presumption that Sessions (which
Connections wrap) are not thread safe.  They may be, but I don't think
they are.

Paul



More information about the Mulgara-general mailing list