Hey Bard,

2008/11/16 Brad Hubbard <[EMAIL PROTECTED]>:
> If I am using MySQL++ in an app which may be accessed by multiple
> browsers concurrently do I need to make sure I am   using
> dedicated-process to ensure thread safety? Do I need to  use any off the
> inbuilt thread safety features of MySQL++ itself or can I code as though
> threading were not an issue?

Wt only assures thread safety to the extent that:

 - Requests to different sessions can (and will) be handled
simultaneously. The few structures that are shared between threads are
protected and session identity (WApplication::instance()) is
implemented using thread local storage.

 - Manipulation to a single session must be serialized. Incoming
requests for a single session are serialized, and you should make sure
you do not manipulate the widget hierarchy outside the normal event
handling, unless you also grab the application lock.

This gives you at least two strategies to use a database within a Wt
application.

The easiest one is to have a database connection per session.
Databases usually (always?) support multiple threads to concurrently
manipulate different connections but only support manipulation of a
connection from one thread, and thus this coincides nicely with Wt's
concurrency support.

If you need to support many concurrent clients, then it may make sense
to use a connection pool per process, since it is often said that
databases scale badly with the number of concurrent connections. Then,
your sessions only borrow an existing connection during the span of a
single transaction. I have no idea whether MySQL++ provides such an
abstraction.

Regards,
koen

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to