Re: Multithreading

From: Warwick Hunter <whunter(at)agile(dot)tv>
To: Leandro Fanzone <leandro(at)hasar(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Multithreading
Date: 2002-04-24 23:58:36
Message-ID: 3CC746AC.9010404@oz.agile.tv
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Leandro

> I'm using the libpq++ library to access PostgreSQL 7, and I need to use
> it from several threads at the same time. Is that supported, id est,
> does it have serialization mechanisms or do I have to mutex it myself?
> Thank you in advance,

[From the doco for 7.2]

1.11. Threading Behavior

libpq is thread-safe as of PostgreSQL 7.0, so long as no two threads
attempt to manipulate the same PGconn object at the same time. In
particular, you cannot issue concurrent queries from different threads
through the same connection object. (If you need to run concurrent
queries, start up multiple connections.)

[...]

I have done this with the libpq interface and I create a connection
per thread and store the pointer to the connection object in
thread specific storage. This means no two threads will access the
same connection.

I am actually using C++ and chose the C interface because the parts
of the C++ interface I was using were a bit hard to use. I implement
the thread local storage by using a class ACE_TSS from the ACE
library with makes thread specific storage really easy
http://www.cs.wustl.edu/~schmidt/ACE.html

Warwick
--
Warwick Hunter Agile TV Corporation
Voice: +61 7 5584 5912 Fax: +61 7 5575 9550
mailto:whunter(at)oz(dot)agile(dot)tv http://www.agile.tv

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Henshall, Stuart - WCP 2002-04-25 08:45:54 Re: support for atomic multi-table updates?
Previous Message Andrew McMillan 2002-04-24 22:48:11 Re: performance problems with subselects