You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oro-user@jakarta.apache.org by "Daniel F. Savarese" <df...@savarese.org> on 2006/03/29 19:15:03 UTC

Re: Perl5Util threadsafe for group() method?

In message <82...@mail.gmail.com>, "Duke 
Tantiprasut" writes:
>Is there any plans to make getMatch() and group() threadsafe?

They are thread-safe.  Concurrent calls to multiple methods will not leave
the object in an inconsistent state.  What I think you're asking is for
the results to be thread-local/thread-specific (i.e., for the last match
found by the calling thread to be returned).  I'm in favor of making that
change, but it may have to be a configurable option to avoid breaking 
existing code that depends on the existing behavior.  The alternatives
are to only store a thread-local match result or to also create a separate
matcher for each thread, which may actually be the better route as it
would no longer be necessary for certain (or any?) methods to be
synchronized.  But it would defeat the intention of having a low memory
footprint (not that matchers hold a lot of state when not executing).
We're not JDK 1.1 compatible anymore on account of using HashMap, so it's
safe to use ThreadLocal.  Supporting J2ME would have required conditional
compilation anyway and is still easy enough to work in should the demand
arise.

Is there a preference for just keeping the match results thread local and
the methods synchronized or using a separate matcher for each thread
without synchronization (access to the pattern cache would still have
to be protected in a critical section)?

daniel

-#-#-#-#-| Sleep and The Traveller |-#-#-#-#-#-#-#- http://www.savarese.org/
In distant lands, I hear the call of my home.     #     s a v a r e s e
Yet my work is not done.  My journey's just begun.-    software research
 -- http://www.sleepandthetraveller.com/          # http://www.savarese.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: oro-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: oro-user-help@jakarta.apache.org


Re: Perl5Util threadsafe for group() method?

Posted by Duke Tantiprasut <du...@gmail.com>.
Both will actually be the same for me. I just use the Perl5Util and dont
explicitly create matchers. The first option sounds like an easier way to go
as well as being easy for most people to understand.

On 3/29/06, Daniel F. Savarese <df...@savarese.org> wrote:
>
>
> In message <82...@mail.gmail.com>,
> "Duke
> Tantiprasut" writes:
> >Is there any plans to make getMatch() and group() threadsafe?
>
> They are thread-safe.  Concurrent calls to multiple methods will not leave
> the object in an inconsistent state.  What I think you're asking is for
> the results to be thread-local/thread-specific (i.e., for the last match
> found by the calling thread to be returned).  I'm in favor of making that
> change, but it may have to be a configurable option to avoid breaking
> existing code that depends on the existing behavior.  The alternatives
> are to only store a thread-local match result or to also create a separate
> matcher for each thread, which may actually be the better route as it
> would no longer be necessary for certain (or any?) methods to be
> synchronized.  But it would defeat the intention of having a low memory
> footprint (not that matchers hold a lot of state when not executing).
> We're not JDK 1.1 compatible anymore on account of using HashMap, so it's
> safe to use ThreadLocal.  Supporting J2ME would have required conditional
> compilation anyway and is still easy enough to work in should the demand
> arise.
>
> Is there a preference for just keeping the match results thread local and
> the methods synchronized or using a separate matcher for each thread
> without synchronization (access to the pattern cache would still have
> to be protected in a critical section)?
>
> daniel
>
> -#-#-#-#-| Sleep and The Traveller |-#-#-#-#-#-#-#-
> http://www.savarese.org/
> In distant lands, I hear the call of my home.     #     s a v a r e s e
> Yet my work is not done.  My journey's just begun.-    software research
> -- http://www.sleepandthetraveller.com/          #
> http://www.savarese.com/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: oro-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: oro-user-help@jakarta.apache.org
>
>