[Haskell-cafe] a question about concurrent haskell
Don Stewart
dons at galois.com
Thu Sep 18 15:35:47 EDT 2008
manlio_perillo:
> Hi.
>
> I have a question about concurrent Haskell in GHC.
>
> Suppose I want to write a native pure Haskell PostgreSQL client.
> I have done this for Python (using Twisted):
> http://hg.mperillo.ath.cx/twisted/pglib/
>
> and I would like to do this in Haskell, as an exercise.
>
> The main problem is with multiple concurrent queries to the same
> connection, from multiple threads.
>
> PostgreSQL supports multiple requests but it's better to execute only
> one request at a time:
> http://www.postgresql.org/docs/8.3/interactive/protocol-flow.html#AEN73647
>
> In the Twisted version I queue all the requests, and every time a
> request completes I call the callback associated with the request and
> execute the next available request.
I'd queue or sychronise all threads requesting the underlying
non-thread safe resource by using either STM transactions, or an MVar.
-- Don
More information about the Haskell-Cafe
mailing list