From: <ta...@us...> - 2009-12-04 16:42:55
|
Revision: 12256 http://x10.svn.sourceforge.net/x10/?rev=12256&view=rev Author: tardieu Date: 2009-12-04 16:42:35 +0000 (Fri, 04 Dec 2009) Log Message: ----------- working on finish (removed RID, used non-immortal remote refs, using global methods) removed free boolean (ie unconditionally dealloc async body) partially fixed race when async get processed before runtime is initialized (race still exists) Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.runtime/src-cpp/x10/lang/Rail.cc trunk/x10.runtime/src-cpp/x10aux/bootstrap.h trunk/x10.runtime/src-cpp/x10aux/network.cc trunk/x10.runtime/src-cpp/x10aux/network.h trunk/x10.runtime/src-x10/x10/runtime/Activity.x10 trunk/x10.runtime/src-x10/x10/runtime/FinishState.x10 trunk/x10.runtime/src-x10/x10/runtime/FinishStates.x10 trunk/x10.runtime/src-x10/x10/runtime/RemoteFinish.x10 trunk/x10.runtime/src-x10/x10/runtime/RootFinish.x10 trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 Removed Paths: ------------- trunk/x10.runtime/src-x10/x10/runtime/RID.x10 Modified: trunk/x10.compiler/src/x10/visit/Desugarer.java =================================================================== --- trunk/x10.compiler/src/x10/visit/Desugarer.java 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.compiler/src/x10/visit/Desugarer.java 2009-12-04 16:42:35 UTC (rev 12256) @@ -386,9 +386,6 @@ synth.toBlock(body), xContext()); exprs.add(closure); types.add(closure.closureDef().asType()); - Expr free = (Expr) xnf.BooleanLit(pos, true).typeCheck(this); - exprs.add(free); - types.add(free.type()); Stmt result = xnf.Eval(pos, synth.makeStaticCall(pos, xts.Runtime(), RUN_ASYNC, exprs, xts.Void(), types, xContext())); Modified: trunk/x10.runtime/src-cpp/x10/lang/Rail.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-cpp/x10/lang/Rail.cc 2009-12-04 16:42:35 UTC (rev 12256) @@ -29,9 +29,8 @@ void x10::lang::Rail_notifyEnclosingFinish(deserialization_buffer& buf) { - x10::runtime::RID rid = buf.read<x10::runtime::RID>(); + ref<Object> fs = buf.read<ref<Object> >(); ref<x10::runtime::Runtime> rt = x10::runtime::Runtime::FMGL(runtime)->get(); - ref<Object> fs = rt->FMGL(finishStates)->get(rid); // olivier says the incr should be just after the notifySubActivitySpawn (fs.operator->()->*(findITable<x10::runtime::FinishState>(fs->_getITables())->notifyActivityCreation))(); (fs.operator->()->*(findITable<x10::runtime::FinishState>(fs->_getITables())->notifyActivityTermination))(); @@ -44,9 +43,7 @@ ref<x10::runtime::Runtime> rt = x10::runtime::Runtime::FMGL(runtime)->get(); ref<Object> fs = rt->currentState(); (fs.operator->()->*(findITable<x10::runtime::FinishState>(fs->_getITables())->notifySubActivitySpawn))(x10::lang::Place_methods::_make(dst)); - rt->FMGL(finishStates)->put(fs); - x10::runtime::RID rid = (fs.operator->()->*(findITable<x10::runtime::FinishState>(fs->_getITables())->rid))(); - buf.write(rid, m); + buf.write(fs, m); } void x10::lang::Rail_serializeAndSendPut(Place dst_place_, ref<Object> df, x10_ubyte code, Modified: trunk/x10.runtime/src-cpp/x10aux/bootstrap.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/bootstrap.h 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-cpp/x10aux/bootstrap.h 2009-12-04 16:42:35 UTC (rev 12256) @@ -103,7 +103,7 @@ #endif setlinebuf(stdout); - x10rt_init(ac,av); + x10aux::network_init(ac,av); x10aux::ref<x10::lang::Rail<x10aux::ref<x10::lang::String> > > args = x10aux::null; @@ -112,15 +112,15 @@ #endif x10aux::place_local::initialize(); - x10aux::DeserializationDispatcher::registerHandlers(); - - args = x10aux::convert_args(ac, av); - // Initialise enough state to make this 'main' thread look like a normal x10 thread // (e.g. make Thread::CurrentThread work properly). x10::runtime::Thread::_make(x10aux::null, x10::lang::String::Lit("thread-main")); x10aux::initialize_xrx(); + x10aux::DeserializationDispatcher::registerHandlers(); + + args = x10aux::convert_args(ac, av); + // Construct closure to invoke the static initialisers at place 0 x10aux::ref<x10::lang::VoidFun_0_0> init_closure = x10aux::ref<StaticInitClosure>(new (x10aux::alloc<x10::lang::VoidFun_0_0>(sizeof(x10aux::StaticInitClosure))) Modified: trunk/x10.runtime/src-cpp/x10aux/network.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.cc 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-cpp/x10aux/network.cc 2009-12-04 16:42:35 UTC (rev 12256) @@ -14,8 +14,9 @@ #include <x10/lang/String.h> // for debug output #include <x10/lang/Closure.h> // for x10_runtime_Runtime__closure__6 -#include <x10/runtime/RID.h> +#include <x10/runtime/Runtime.h> + using namespace x10::lang; using namespace x10aux; @@ -110,13 +111,17 @@ void x10aux::registration_complete (void) { + x10aux::kernel_put = + x10rt_register_put_receiver(NULL, NULL, kernel_put_finder, kernel_put_notifier); x10rt_registration_complete(); + x10aux::x10rt_initialized = true; +} + +void x10aux::network_init (int ac, char **av) { + x10rt_init(ac, av); x10aux::here = x10rt_here(); x10aux::num_places = x10rt_nplaces(); x10aux::num_hosts = x10rt_nhosts(); - x10aux::kernel_put = - x10rt_register_put_receiver(NULL, NULL, kernel_put_finder, kernel_put_notifier); - x10aux::x10rt_initialized = true; } /* @@ -146,7 +151,7 @@ struct x10_runtime_Runtime__closure__6__hack : x10::lang::Closure { static const x10aux::serialization_id_t _serialization_id; x10aux::ref<x10::lang::VoidFun_0_0> body; - x10::runtime::RID rid; + x10aux::ref<x10::lang::Object> fs; }; void x10aux::run_at(x10aux::place p, x10aux::ref<Object> body) { @@ -191,7 +196,7 @@ x10aux::ref<x10::lang::Object> real_body = body_->body; - x10::runtime::RID rid = body_->rid; + x10aux::ref<x10::lang::Object> fs = body_->fs; serialization_id_t real_sid = real_body->_get_serialization_id(); msg_type real_id = DeserializationDispatcher::getMsgType(real_sid); @@ -200,7 +205,7 @@ <<ref<Object>(real_body)->toString()->c_str()<<" id "<<real_id <<" sid "<<real_sid<<" at GPU: "<<p); - x10::runtime::RID::_serialize(rid, buf, m); + buf.write(fs, m); real_body->_serialize_body(buf, m); unsigned long sz = buf.length(); @@ -266,7 +271,7 @@ { _X_(ANSI_X10RT<<"Receiving a kernel pre callback, deserialising..."<<ANSI_RESET); x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); - buf.read<x10::runtime::RID>(); + buf.read<x10aux::ref<x10::lang::Object> >(); // note: high bytes thrown away in implicit conversion serialization_id_t sid = x10aux::DeserializationDispatcher::getSerializationId(p.type); x10aux::CUDAPre pre = x10aux::DeserializationDispatcher::getCUDAPre(sid); @@ -280,9 +285,8 @@ _X_(ANSI_X10RT<<"Receiving a kernel post callback, deserialising..."<<ANSI_RESET); remote_free(p.dest_place, (x10_ulong)(size_t)env); x10aux::deserialization_buffer buf(static_cast<char*>(p.msg)); - x10::runtime::RID rid = buf.read<x10::runtime::RID>(); + x10aux::ref<x10::lang::Object> fs = buf.read<x10aux::ref<x10::lang::Object> >(); x10aux::ref<x10::runtime::Runtime> rt = x10::runtime::Runtime::FMGL(runtime)->get(); - x10aux::ref<x10::lang::Object> fs = rt->FMGL(finishStates)->get(rid); (fs.operator->()->*(x10aux::findITable<x10::runtime::FinishState>(fs->_getITables())->notifyActivityCreation))(); (fs.operator->()->*(x10aux::findITable<x10::runtime::FinishState>(fs->_getITables())->notifyActivityTermination))(); } Modified: trunk/x10.runtime/src-cpp/x10aux/network.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.h 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-cpp/x10aux/network.h 2009-12-04 16:42:35 UTC (rev 12256) @@ -60,6 +60,8 @@ void registration_complete (void); + void network_init (int ac, char **av); + inline void *msg_realloc(void *old, size_t old_sz, size_t new_sz) { return x10rt_msg_realloc(old, old_sz, new_sz); } Modified: trunk/x10.runtime/src-x10/x10/runtime/Activity.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/Activity.x10 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-x10/x10/runtime/Activity.x10 2009-12-04 16:42:35 UTC (rev 12256) @@ -17,15 +17,12 @@ /** * the finish state governing the execution of this activity */ - val finishState:FinishState!; + val finishState:FinishState; + /** * safe to run pending jobs while waiting for a finish (temporary) */ val safe:Boolean; - /** - * whether to dealloc the body after executing it - */ - private val free:Boolean; /** * The user-specified code for this activity. @@ -42,30 +39,22 @@ * The finish states for the finish statements currently executed by this activity. * Lazily created. */ - var finishStack:Stack[FinishState!]!; + var finishStack:Stack[FinishState]!; /** * Create activity. */ - def this(body:()=>Void, finishState:FinishState!, safe:Boolean) { - this(body, finishState, safe, false); - } - - /** - * Create activity. - */ - def this(body:()=>Void, finishState:FinishState!, safe:Boolean, free:Boolean) { + def this(body:()=>Void, finishState:FinishState, safe:Boolean) { this.finishState = finishState; this.safe = safe; finishState.notifyActivityCreation(); this.body = body; - this.free = free; } /** * Create clocked activity. */ - def this(body:()=>Void, finishState:FinishState{self.at(here)}, clocks:ValRail[Clock], phases:ValRail[Int]) { + def this(body:()=>Void, finishState:FinishState, clocks:ValRail[Clock], phases:ValRail[Int]) { this(body, finishState, false); clockPhases = ClockPhases.make(clocks, phases); } @@ -81,11 +70,8 @@ } if (null != clockPhases) clockPhases.drop(); finishState.notifyActivityTermination(); - if (free) NativeRuntime.dealloc(body); + NativeRuntime.dealloc(body); } - - // [DC] The correct thing to do here is do toString() on the closure - // public def toString():String = name; } // vim:shiftwidth=4:tabstop=4:expandtab Modified: trunk/x10.runtime/src-x10/x10/runtime/FinishState.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/FinishState.x10 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-x10/x10/runtime/FinishState.x10 2009-12-04 16:42:35 UTC (rev 12256) @@ -9,27 +9,28 @@ package x10.runtime; /** - * @author tardieu + * @author tardieu */ interface FinishState { /** - * An activity created under this finish has been created. Increment the count - * associated with the finish. + * An activity is spawned under this finish (called by spawner). */ - def notifySubActivitySpawn(place:Place):Void; + global def notifySubActivitySpawn(place:Place):Void; + /** + * An activity is created under this finish (called by spawnee). + */ + global def notifyActivityCreation():Void; + /** * An activity created under this finish has terminated. + * Also called be the activity governing the finish when it completes the finish body. */ - def notifyActivityTermination():Void; + global def notifyActivityTermination():Void; /** * Push an exception onto the stack. */ - def pushException(t:Throwable):Void; - - def rid(): RID; - - def notifyActivityCreation():Void; + global def pushException(t:Throwable):Void; } Modified: trunk/x10.runtime/src-x10/x10/runtime/FinishStates.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/FinishStates.x10 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-x10/x10/runtime/FinishStates.x10 2009-12-04 16:42:35 UTC (rev 12256) @@ -8,60 +8,29 @@ package x10.runtime; +import x10.util.concurrent.atomic.AtomicInteger; import x10.util.HashMap; -import x10.util.concurrent.atomic.AtomicInteger; - -import x10.io.Console; - /** * @author tardieu */ -class FinishStates { +class FinishStates implements (RootFinish)=>RemoteFinish { - private val map = new HashMap[RID, FinishState!](); - private val count = new AtomicInteger(0); + private val map = new HashMap[RootFinish, RemoteFinish!](); private val lock = new Lock(); - def put(finishState:FinishState!):Void { - if (finishState.rid().id == -1) { - lock.lock(); - if (finishState.rid().id == -1) { - val rootFinish = finishState as RootFinish!; - rootFinish.rid = RID(here, count.getAndIncrement()); - map.put(rootFinish.rid, rootFinish); - } - lock.unlock(); - } - } - - def get(rid:RID):FinishState! { + public def apply(rootFinish:RootFinish):RemoteFinish { lock.lock(); - val finishState = map.getOrElse(rid, null); + val finishState = map.getOrElse(rootFinish, null); if (null != finishState) { lock.unlock(); return finishState; } - val remoteFinish = new RemoteFinish(rid); - map.put(rid, remoteFinish); + val remoteFinish = new RemoteFinish(); + map.put(rootFinish, remoteFinish); lock.unlock(); return remoteFinish; } - - def findRoot(rid:RID):RootFinish { - lock.lock(); - val finishState = map.getOrElse(rid, null); - lock.unlock(); - return finishState as RootFinish; - } - - def removeRoot(rootFinish:RootFinish!):Void{ - if (rootFinish.rid.id != -1) { - lock.lock(); - map.remove(rootFinish.rid); - lock.unlock(); - } - } } // vim:shiftwidth=4:tabstop=4:expandtab Deleted: trunk/x10.runtime/src-x10/x10/runtime/RID.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/RID.x10 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-x10/x10/runtime/RID.x10 2009-12-04 16:42:35 UTC (rev 12256) @@ -1,9 +0,0 @@ -package x10.runtime; - -public final struct RID(place:Place, id:Int) { - public def this(place:Place, id:Int) = property(place, id); - - public def hashCode():Int = id; - public incomplete def toString():String; - -} Modified: trunk/x10.runtime/src-x10/x10/runtime/RemoteFinish.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/RemoteFinish.x10 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-x10/x10/runtime/RemoteFinish.x10 2009-12-04 16:42:35 UTC (rev 12256) @@ -16,7 +16,7 @@ /** * @author tardieu */ -class RemoteFinish implements FinishState { +class RemoteFinish { /** * The Exception Stack is used to collect exceptions * issued when activities associated with this finish state terminate abruptly. @@ -38,14 +38,6 @@ private var count:AtomicInteger = new AtomicInteger(0); - private val rid:RID; - - def this(rid:RID) { - this.rid = rid; - } - - public def rid():RID = rid; - public def notifyActivityCreation():Void { count.getAndIncrement(); } @@ -65,7 +57,7 @@ /** * An activity created under this finish has terminated. */ - public def notifyActivityTermination():Void { + public def notifyActivityTermination(r:RootFinish):Void { lock.lock(); counts(here.id)--; if (count.decrementAndGet() > 0) { @@ -79,7 +71,6 @@ for (var i:Int=0; i<Place.MAX_PLACES; i++) counts(i) = 0; length = 1; lock.unlock(); - val r = rid; if (null != e) { val t:Throwable; if (e.size() == 1) { @@ -87,12 +78,12 @@ } else { t = new MultipleExceptions(e); } - val closure = () => { Runtime.findRoot(r).notify(m, t); NativeRuntime.deallocObject(m); }; - NativeRuntime.runAt(rid.place.id, closure); + val closure = () => { (r as RootFinish!).notify(m, t); NativeRuntime.deallocObject(m); }; + NativeRuntime.runAt(r.home.id, closure); NativeRuntime.dealloc(closure); } else { - val closure = () => { Runtime.findRoot(r).notify(m) ; NativeRuntime.deallocObject(m); }; - NativeRuntime.runAt(rid.place.id, closure); + val closure = () => { (r as RootFinish!).notify(m); NativeRuntime.deallocObject(m); }; + NativeRuntime.runAt(r.home.id, closure); NativeRuntime.dealloc(closure); } NativeRuntime.deallocObject(m); @@ -101,7 +92,6 @@ for (var i:Int=0; i<Place.MAX_PLACES; i++) counts(i) = 0; length = 1; lock.unlock(); - val r = rid; if (null != e) { val t:Throwable; if (e.size() == 1) { @@ -109,12 +99,12 @@ } else { t = new MultipleExceptions(e); } - val closure = () => { Runtime.findRoot(r).notify2(m, t); NativeRuntime.deallocObject(m); }; - NativeRuntime.runAt(rid.place.id, closure); + val closure = () => { (r as RootFinish!).notify2(m, t); NativeRuntime.deallocObject(m); }; + NativeRuntime.runAt(r.home.id, closure); NativeRuntime.dealloc(closure); } else { - val closure = () => { Runtime.findRoot(r).notify2(m) ; NativeRuntime.deallocObject(m); }; - NativeRuntime.runAt(rid.place.id, closure); + val closure = () => { (r as RootFinish!).notify2(m) ; NativeRuntime.deallocObject(m); }; + NativeRuntime.runAt(r.home.id, closure); NativeRuntime.dealloc(closure); } NativeRuntime.deallocObject(m); Modified: trunk/x10.runtime/src-x10/x10/runtime/RootFinish.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/RootFinish.x10 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-x10/x10/runtime/RootFinish.x10 2009-12-04 16:42:35 UTC (rev 12256) @@ -14,27 +14,45 @@ /** * @author tardieu */ -class RootFinish extends Latch implements FinishState { +class RootFinish extends Latch implements FinishState, Mortal { private val counts:Rail[Int]!; - private var exceptions:Stack[Throwable]!; - var rid:RID = RID(here, -1); - - public def rid():RID = rid; - - public def notifyActivityCreation():Void {} - def this() { val c = Rail.make[Int](Place.MAX_PLACES, (Int)=>0); c(here.id) = 1; counts = c; } + + private def notifySubActivitySpawnLocal(place:Place):Void { + lock(); + counts(place.parent().id)++; + unlock(); + } + private def notifyActivityTerminationLocal():Void { + lock(); + counts(here.id)--; + for(var i:Int=0; i<Place.MAX_PLACES; i++) { + if (counts(i) != 0) { + unlock(); + return; + } + } + release(); + unlock(); + } + + private def pushExceptionLocal(t:Throwable):Void { + lock(); + if (null == exceptions) exceptions = new Stack[Throwable](); + exceptions.push(t); + unlock(); + } + def waitForFinish(safe:Boolean):Void { if (!NativeRuntime.NO_STEALS && safe) Runtime.join(this); await(); - Runtime.removeRoot(this); if (null != exceptions) { if (exceptions.size() == 1) { val t = exceptions.peek(); @@ -76,38 +94,40 @@ } def notify(rail:ValRail[Int]!, t:Throwable):Void { - pushException(t); + pushExceptionLocal(t); notify(rail); } def notify2(rail:ValRail[Pair[Int,Int]]!, t:Throwable):Void { - pushException(t); + pushExceptionLocal(t); notify2(rail); } - public def notifySubActivitySpawn(place:Place):Void { - lock(); - counts(place.parent().id)++; - unlock(); + public global def notifySubActivitySpawn(place:Place):Void { + if (here.equals(home)) { + (this as RootFinish!).notifySubActivitySpawnLocal(place); + } else { + Runtime.proxy(this).notifySubActivitySpawn(place); + } } + + public global def notifyActivityCreation():Void { + if (!here.equals(home)) Runtime.proxy(this).notifyActivityCreation(); + } - public def notifyActivityTermination():Void { - lock(); - counts(here.id)--; - for(var i:Int=0; i<Place.MAX_PLACES; i++) { - if (counts(i) != 0) { - unlock(); - return; - } - } - release(); - unlock(); + public global def notifyActivityTermination():Void { + if (here.equals(home)) { + (this as RootFinish!).notifyActivityTerminationLocal(); + } else { + Runtime.proxy(this).notifyActivityTermination(this); + } } - public def pushException(t:Throwable):Void { - lock(); - if (null == exceptions) exceptions = new Stack[Throwable](); - exceptions.push(t); - unlock(); + public global def pushException(t:Throwable):Void { + if (here.equals(home)) { + (this as RootFinish!).pushExceptionLocal(t); + } else { + Runtime.proxy(this).pushException(t); + } } } Modified: trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 2009-12-04 15:06:46 UTC (rev 12255) +++ trunk/x10.runtime/src-x10/x10/runtime/Runtime.x10 2009-12-04 16:42:35 UTC (rev 12256) @@ -45,12 +45,9 @@ */ private const runtime = PlaceLocalHandle.createHandle[Runtime](); + static def proxy(rootFinish:RootFinish) = runtime().finishStates(rootFinish); + /** - * Return the current runtime - */ - //private static def runtime() = runtime.get() as Runtime!; - - /** * Return the current worker */ private static def worker():Worker! = Thread.currentThread().worker(); @@ -109,68 +106,49 @@ runtime().pool.release(); } - static def findRoot(rid:RID) = runtime().finishStates.findRoot(rid) as RootFinish!; - - static def removeRoot(rootFinish:RootFinish!) { - runtime().finishStates.removeRoot(rootFinish); - } - - // async -> at statement -> at expression -> future // do not introduce cycles!!! /** * Run async */ - public static def runAsync(place:Place, clocks:ValRail[Clock], body:()=>Void, Boolean):Void { + public static def runAsync(place:Place, clocks:ValRail[Clock], body:()=>Void):Void { val state = currentState(); val phases = clockPhases().register(clocks); state.notifySubActivitySpawn(place); if (place.id == Thread.currentThread().locInt()) { execute(new Activity(body, state, clocks, phases)); } else { - runtime().finishStates.put(state); - val rid = state.rid(); - val c = ()=>execute(new Activity(body, runtime().finishStates.get(rid), clocks, phases)); + val c = ()=>execute(new Activity(body, state, clocks, phases)); NativeRuntime.runAt(place.id, c); } } - public static def runAsync(place:Place, body:()=>Void, free:Boolean):Void { + public static def runAsync(place:Place, body:()=>Void):Void { val state = currentState(); state.notifySubActivitySpawn(place); val ok = safe(); if (place.id == Thread.currentThread().locInt()) { - execute(new Activity(body, state, ok, free)); + execute(new Activity(body, state, ok)); } else { - runtime().finishStates.put(state); - val rid = state.rid(); var closure:()=>Void; // val closure = -// ok ? (free ? ()=>execute(new Activity(body, runtime().finishStates.get(rid), true, true)) -// : ()=>execute(new Activity(body, runtime().finishStates.get(rid), true, false))) -// : (free ? ()=>execute(new Activity(body, runtime().finishStates.get(rid), false, true)) -// : ()=>execute(new Activity(body, runtime().finishStates.get(rid), false, false))); +// ok ? (free ? ()=>execute(new Activity(body, state, true, true)) +// : ()=>execute(new Activity(body, state, true, false))) +// : (free ? ()=>execute(new Activity(body, state, false, true)) +// : ()=>execute(new Activity(body, state, false, false))); // Workaround for XTENLANG_614 if (ok) { - if (free) { - closure = ()=>execute(new Activity(body, runtime().finishStates.get(rid), true, true)); - } else { - closure = ()=>execute(new Activity(body, runtime().finishStates.get(rid), true, false)); - } + closure = ()=>execute(new Activity(body, state, true)); } else { - if (free) { - closure = ()=>execute(new Activity(body, runtime().finishStates.get(rid), false, true)); - } else { - closure = ()=>execute(new Activity(body, runtime().finishStates.get(rid), false, false)); - } + closure = ()=>execute(new Activity(body, state, false)); } NativeRuntime.runAt(place.id, closure); NativeRuntime.dealloc(closure); } } - public static def runAsync(clocks:ValRail[Clock], body:()=>Void, Boolean):Void { + public static def runAsync(clocks:ValRail[Clock], body:()=>Void):Void { val state = currentState(); val phases = clockPhases().register(clocks); state.notifySubActivitySpawn(here); @@ -178,13 +156,9 @@ } public static def runAsync(body:()=>Void):Void { - runAsync(body, false); - } - - public static def runAsync(body:()=>Void, free:Boolean):Void { val state = currentState(); state.notifySubActivitySpawn(here); - execute(new Activity(body, state, safe(), free)); + execute(new Activity(body, state, safe())); } /** @@ -192,10 +166,10 @@ */ public static def runAt(place:Place, body:()=>Void):Void { //avoid creating another closure - //finish async (place) body(); - startFinish(); - runAsync(place, body, false); - stopFinish(); + finish async (place) body(); + //startFinish(); + //runAsync(place, body); + //stopFinish(); } /** @@ -324,11 +298,11 @@ /** * Return the innermost finish state for the current activity */ - private static def currentState(): FinishState! { + private static def currentState():RootFinish { val a = activity(); if (null == a.finishStack || a.finishStack.isEmpty()) - return a.finishState; - return a.finishStack.peek(); + return a.finishState as RootFinish; + return a.finishStack.peek() as RootFinish; } /** @@ -338,7 +312,7 @@ public static def startFinish():Void { val a = activity(); if (null == a.finishStack) - a.finishStack = new Stack[FinishState!](); + a.finishStack = new Stack[FinishState](); a.finishStack.push(new RootFinish()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |