An alternative is to use synchronized(this) surrounding the code in the
advice.
before() : myPC() {
synchronized(this) {
... advice code ...
}
}
-Ramnivas
Matthew Webster wrote:
The simple solution is to delegate
the
logic in you advice to a synchronized instance method in the aspect. If
you are using default aspect instantiation it will be a singleton
guaranteeing
that only one thread will execute the logic at a time. If you need to
use
thisJoinPoint/thisJoinPointStaticPart their values can be passes as
arguments
to the new method.
Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester, SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/
Well, I tryed to use the synchronized keyword
writing:
synchronized before ....
but I have a compile error which says:
illegal modifier on advice, only strictfp allowed
For this reason I'm looking for another solution if it exists. Do you
have
any idea?
bye
lollo82
----- Original Message -----
From: "Eric Bodden" <eric.bodden@xxxxxxxxxxxxxx>
To: <aspectj-users@xxxxxxxxxxx>
Sent: Wednesday, July 19, 2006 10:09 PM
Subject: RE: [aspectj-users] Can I declare an advice as synchronized
Hi.
> I'm using aspect in an concurrent application and I'd
like to be
> sure that the advices are synchronized. In fact I don't want that
more
> than one thread per time runs the advice code. Can I acchieve this
> result? I read that an aspect is a singleton on the aspectJ guide,
does
> it imply that only one thread per time is inside it?
No, that is not implied (as it is not for any other regular singleton).
But you can just use the synchronized keyword for your advice AFAIK.
Eric
--
Eric Bodden
Sable Research Group, McGill University
Montreal, Canada
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users
|