You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Paul Libbrecht <pa...@activemath.org> on 2004/12/16 16:43:38 UTC

[jelly] Trying to understand ThreadLocal story

Dear Jellyers,

Since it really seems this tag-caching story is biting the most normal 
activity I ever had with Jelly, I'm starting to try to think of it.
Careful... this mail is freshly thought whereas many have put many 
thoughts in there.

Do I understand the problem correctly as follows?
• Scripts are built at compile time (maybe this doesn't really matter)
• Tag objects, however, can store states (e.g. UseBeanTag stores a 
bean, many others do something else) and, as a result, should only be 
created at run time. This way two threads can traverse the script 
simultaneously and not share states (as one expects).

The way this was implemented was to make a ThreadLocal which has bad 
habit of not being possible to clear correctly. The patch applied 
suggested a weak-reference at the parent-child-body separation of 
script so that it still gets cleared in some way, this seemed to have 
gone too far.

Now... aren't we >just< missing a simple notion "run-session", passed 
between script-objects, where each TagScript could put it's tag ?
A simple hash-table where the key is the tag-script seems to satisfy 
requirements.
That run-session, in normal conditions, would be garbage collected at 
the end of the run(), at least.

After my unhappy (yet) attempts at reloadable tags, I would start to 
understand things if such a session existed.
But maybe I have thought aloud too quickly...

paul


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


RE: [jelly] Trying to understand ThreadLocal story

Posted by Hans Gilde <hg...@earthlink.net>.
I agree that it's cleaner but here's why I didn't do it:

It's important for the cache to exist because some tags need it just to run.
So, I didn't want to keep the cache in with the context variables because
that data is vulnerable to inherit/export setting on the context. If the
cache is broken while the Script is running, some tags will break.

We decided that we didn't want to change the API of JellyContext... so I
didn't know where to keep the cache.

Maybe it's better to bite the bullet and implement a cache in the context.
But, it might be a very temporary API change.

-----Original Message-----
From: Dion Gillard [mailto:dion.gillard@gmail.com] 
Sent: Thursday, December 16, 2004 8:30 PM
To: Jakarta Commons Developers List
Subject: Re: [jelly] Trying to understand ThreadLocal story

This sounds a lot cleaner to me.


On Thu, 16 Dec 2004 18:37:11 -0500, peter royal <pr...@apache.org> wrote:
> On Dec 16, 2004, at 10:43 AM, Paul Libbrecht wrote:
> > Now... aren't we >just< missing a simple notion "run-session", passed
> > between script-objects, where each TagScript could put it's tag ?
> > A simple hash-table where the key is the tag-script seems to satisfy
> > requirements.
> > That run-session, in normal conditions, would be garbage collected at
> > the end of the run(), at least.
> 
> Basically, yes. Rather than caching tags in the TagScript, we
> could/should cache them in a JellyContext. You could then discards the
> JellyContext to force the Tag's to be GC'd
> -pete
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 
> 


-- 
http://www.multitask.com.au/people/dion/

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


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


Re: [jelly] Trying to understand ThreadLocal story

Posted by Dion Gillard <di...@gmail.com>.
This sounds a lot cleaner to me.


On Thu, 16 Dec 2004 18:37:11 -0500, peter royal <pr...@apache.org> wrote:
> On Dec 16, 2004, at 10:43 AM, Paul Libbrecht wrote:
> > Now... aren't we >just< missing a simple notion "run-session", passed
> > between script-objects, where each TagScript could put it's tag ?
> > A simple hash-table where the key is the tag-script seems to satisfy
> > requirements.
> > That run-session, in normal conditions, would be garbage collected at
> > the end of the run(), at least.
> 
> Basically, yes. Rather than caching tags in the TagScript, we
> could/should cache them in a JellyContext. You could then discards the
> JellyContext to force the Tag's to be GC'd
> -pete
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 
> 


-- 
http://www.multitask.com.au/people/dion/

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


RE: [jelly] Trying to understand ThreadLocal story

Posted by Hans Gilde <hg...@earthlink.net>.
Or maybe as a stack, passed down from invocation to invocation. Since we're
trying to separate stuff from the context as much as possible. But this
would be a big API change.

-----Original Message-----
From: peter royal [mailto:proyal@apache.org] 
Sent: Thursday, December 16, 2004 6:37 PM
To: Jakarta Commons Developers List
Subject: Re: [jelly] Trying to understand ThreadLocal story

On Dec 16, 2004, at 10:43 AM, Paul Libbrecht wrote:
> Now... aren't we >just< missing a simple notion "run-session", passed 
> between script-objects, where each TagScript could put it's tag ?
> A simple hash-table where the key is the tag-script seems to satisfy 
> requirements.
> That run-session, in normal conditions, would be garbage collected at 
> the end of the run(), at least.

Basically, yes. Rather than caching tags in the TagScript, we 
could/should cache them in a JellyContext. You could then discards the 
JellyContext to force the Tag's to be GC'd
-pete


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


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


Re: [jelly] Trying to understand ThreadLocal story

Posted by peter royal <pr...@apache.org>.
On Dec 16, 2004, at 10:43 AM, Paul Libbrecht wrote:
> Now... aren't we >just< missing a simple notion "run-session", passed 
> between script-objects, where each TagScript could put it's tag ?
> A simple hash-table where the key is the tag-script seems to satisfy 
> requirements.
> That run-session, in normal conditions, would be garbage collected at 
> the end of the run(), at least.

Basically, yes. Rather than caching tags in the TagScript, we 
could/should cache them in a JellyContext. You could then discards the 
JellyContext to force the Tag's to be GC'd
-pete


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