From 9158a0bd5875bf0e1c3c7852389625c66069bca8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 25 Mar 2011 14:15:11 +0200 Subject: Make queries without by-reference parameters immutable This makes it possible to share such queries between multiple threads without the need for synchronization. --- doc/manual.xhtml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/manual.xhtml b/doc/manual.xhtml index 2744a7e..b586bf9 100644 --- a/doc/manual.xhtml +++ b/doc/manual.xhtml @@ -3134,9 +3134,16 @@ namespace odb result r1 (db.query<person> (query::first == "John")); -

Normally we would create a named query instance if we are +

Normally, we would create a named query instance if we are planning to run the same query multiple times and would use the - in-line version for those that are executed only once.

+ in-line version for those that are executed only once. A named + query instance that does not have any by-reference parameters is + immutable and can be shared between multiple threads without + synchronization. On the other hand, a query instance with + by-reference parameters is modified every time it is executed. + If such a query is shared among multiple threads, then access + to this query instance must be synchronized from the execution + point and until the completion of the iteration over the result.

It is also possible to create queries from other queries by combining them using logical operators. For example:

-- cgit v1.1