You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Tim Kimber <KI...@uk.ibm.com> on 2005/02/16 18:20:35 UTC

Pre-compiling regular expressions, thread safety




Hi,

I notice that regular expression objects (instances of
rgxRegularExpression) are prepared/compiled only when the matches() method
is called.
In my application, this a little inconvenient - I would rather create *and
prepare* all the regular expression objects which I know I will require, so
that the cost is incurred once, and
up-front. However, I would like to store the prepared objects in a data
structure which is shared across a number of threads.

My questions:
a) would it be reasonable (in my own code) to call the prepare() method in
the constructor, rather than in the matches() method
b) would it be safe for such a prepared/compiled rgxRegularExpression
object to be executed (i.e. have its matches() method called )
simultaneously from more than one thread.

regards,

Tim Kimber, MRM Development Team
Internet:  kimbert@uk.ibm.com
Tel. 01962-816742
Internal tel. 246742


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org