Here's a proposal:

private ClassA valueA;

public synchronized ClassA timeComsumingCallA() {
  if( valueA == null ) {
    valueA = ...compute...
  }
  return valueA;
}

same with B, then implement callDependingOnAandB() and just use 
timeConsumingCallA() and ...B() there. Make that method synchronized as well. 
That way your methods don't even depend on execution order because each value 
will be computed on demand, and only once.

Strictly speaking, the WO RR-Loop is not multithreaded so you won't probably 
need the synchronized keywords in this case, but I suggest you make it a habit 
to do so anyway. I will save you trouble e.g. if you later decide to move code 
to other classes where the values get shared between sessions.

Don't write the Java code in a way that depends on WO implementation details. 
Who knows, perhaps one day someone submits multithreaded stuff into Wonder that 
would break your stuff.

Maik

Am 10.12.2012 um 19:41 schrieb Louis-Olivier Roof 
<[email protected]>:

> Hello WebObjects community, this is my first question so don't be too hard on 
> me ;)
> 
> Lets say I have a wo:loop  in a component...
> 
>      <wo:loop list = "$dg.displayedObjects" item = "$aItem">
>         <tr>
>           <td> <wo:string value = "$~timeConsumingCallA()" /> </td>
>           <td> <wo:string value = "$~timeConsumingCallB()" /> </td>
>           <td> <wo:string value = "$~callDependingOn_A_and_B()" /> </td>
>         </tr>
>       </wo:loop>
> 
> Functions timeConsumingCallA() and timeConsumingCallB() are, as their name 
> imply, costly calls.
> Function callDependingOn_A_and_B() depends on the results of the two first 
> functions.
> 
> Is there any guarantee that the two function calls (timeConsumingCallA, 
> timeConsumingCallB) will always be called in order and before 
> callDependingOn_A_and_B() so I can set and depend on instance variables 
> $timeConsumingCallA_result and $timeConsumingCallB_result in the 
> callDependingOn_A_and_B() function?
> 
> If not, I can see a number of ways I could myself make sure the calls are 
> made in the correct order in straight-Java, but I was wondering if there was 
> a "Wonder/WebObjects" strategy to approach this.
> 
> Thanks for your time,
> 
> -- 
> Louis-Olivier Roof, Eng.
> Software Engineer
> Obzerv Technologies Inc.
> 400, Jean-Lesage, suite 201,
> Québec (Québec)
> Canada, G1K 8W1
> T. (418) 524-3522
> F. (418) 524-6745
> www.obzerv.com
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      ([email protected])
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/maik%40selbstdenker.ag
> 
> This email sent to [email protected]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to