Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] if and loop pointcuts

(sorry for going silent on this)

                   \
----deep end----    \
                     \
                      \
               warning! this message
               goes somewhat this way
                        \
                         \
                         v

Diana (et. al.),

While working on the language, we had an idea for a pointcut called
enclosingexecution. The idea was that it was a kind of "backwards"
withincode. It went from things in the body of the method to the
method execution join point.  So, for example, 

  enclosingexecution(set(* Resource.*))

would be the execution join points of any method that lexically included
sets to fields of Resource objects.  (You could of course replace the set
pointcut with any other pointcut.)

The idea was that enclosing execution would be useful exactly for the
kind of case you have. We could say "if a method writes an object, then
lock it around the entire method body".

But we never could see how to get it to work right. The problem was that
it was hard to believe that anything like:

 pointcut lockPoints(Foo o): enclosingExecution(set(<something>));

 before(Foo o): lockPoints(o) { lockIt(o); }
 after (Foo o): lockPoints(o) { unlockIt(o); }

would be right very often. What about cases where the right place to
lock is actually higher up in the call chain?  How does that get
managed?

As I recall, that's why we stopped working on enclosingexecution. But
I'm not sure enclosingexecution is actually a bad idea. It may just be
that it needs more work than we had time to do. Or it *may* need a kind
of transitive closure or hoist pointcut, and that *may* not be tractable.

So that's why I think your example is interesting. If you have an
example where you can automatically add optimized locking, based
just on knowing where set/get joinpoints are, then it could be input
to trying to get something like enclosingexecution to work.

Maybe anyways. Some others may be more skeptical that anything like
enclosingexecution could work.

What's the status of your example now?

> -----Original Message-----
> From: aspectj-users-admin@xxxxxxxxxxx 
> [mailto:aspectj-users-admin@xxxxxxxxxxx] On Behalf Of Diana 
> Szentivanyi
> Sent: Thursday, August 21, 2003 2:42 AM
> To: aspectj-users@xxxxxxxxxxx
> Subject: RE: [aspectj-users] if and loop pointcuts
> 
> 
>  --- Gregor Kiczales <gregor@xxxxxxxxx> wrote: > 
> 
> >> No, I want to have an aspect that takes a lock at
> the 
> >> first access to a 
> >> variable (this is easy to detect) and releases the
> lock after 
> >> the last access to 
> >> that variable (and here comes my problem).
> 
> >Before thinking about this more, I want to ask why
> you don't want to do
> >the simpler thing of just releasing the lock when the
> enclosing method
> >terminates? It seems to me that you'll have a lot of
> overhead for counting
> >gets/sets and figuring out which path you are on.
> >While I can see that
> >minimizing the locking window is good, I wonder if
> >you'll be paying so
> >much for it that it won't be worth it.
> 
> >I see some other issues, but I wanted to ask this
> question first, before
> >trying to think about those other issues.
> 
> 
>    Actually, I do not want to count gets/sets. I do
> not want to detect (by code in an advice) where is the
> first access to a variable, either. 
>    If I would do the lock take/release by hand in the
> application code, I would know (see) exactly where the
> first and last access to a variable is. 
>    The reason why I need to count accesses and compare
> to a given value to detect the last access,
> respectively use a boolean variable and simple test to
> detect the first access, is that I did not figure out
> how to "say" in AspectJ that the "take lock" advice
> code should be weaved in before only the first access,
> and the "release lock" advice code should be weaved in
> after only the last access.
>    I know that there is an if(boolean_expr) that can
> be used to define pointcuts, but that (as far as I
> understood) only allows static variables in its
> expression, and that is not good for me. 
> 
> 
>         Thank you again,
>            Diana.
> 
> ______________________________________________________________
> __________
> Want to chat instantly with your online friends?  Get the FREE Yahoo!
> Messenger http://uk.messenger.yahoo.com/
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 



Back to the top