Ganesh Venkateshwara <tovgan...@yahoo.co.in> wrote on 03/19/2010 01:27:51 AM:
> Hi, > > I am trying to use await with an async operation as in the attached > code. The code compiles, but it simply waits infinitely at the await statement. > I am most probably doing something strange, and await is not expected > to work like this? > > Let me know if any of you have tried using await for such scenario. Hi, Ganesh, I believe you're only guaranteed to see the results of an atomic update in the when (await) expression. Try changing the relevant lines to async atomic inc.increment(); await inc.incremented; Hope this helps, Igor > ----------------------------------------------------- > public class test { > class Incrementor { > var i:Int; > var incremented:Boolean; > > public def this() { > i = 0; > incremented = false; > } > > public def increment() { > Console.OUT.println("Entering increment(): " + incremented); > > i++; > incremented = true; > > Console.OUT.println("Leaving increment(): " + incremented); > } > } > > def func() { > val inc = new Incrementor(); > > async inc.increment(); > await inc.incremented; > > Console.OUT.println("Its done: " + inc.i); > } > > public static def main(args:Rail[String]) { > (new test()).func(); > } > } > ----------------------------------------------------- -- Igor Peshansky (note the spelling change!) IBM T.J. Watson Research Center X10: Parallel Productivity and Performance (http://x10-lang.org/) XJ: No More Pain for XML's Gain (http://www.research.ibm.com/xj/) "I hear and I forget. I see and I remember. I do and I understand" -- Confucius ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ X10-users mailing list X10-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/x10-users