public ElaAsync RunAsync(ElaFunction fun) { var ret = new ElaAsync(this, fun); ret.Run(); return(ret); }
public ElaValue GetValue(ElaAsync obj) { if (HasValue(obj)) return obj.Return; else { Wait(Int32.MaxValue, obj); if (!HasValue(obj)) throw new ElaRuntimeException("AsyncNoValue", "Unable to obtain a value of an async computation."); return obj.Return; } }
public ElaUnit Wait(int timeout, ElaAsync obj) { var th = obj.Thread; if (th != null) { if (th.Join(timeout)) { lock (syncRoot) { Threads.Remove(th); obj.Thread = null; } } } return(ElaUnit.Instance); }
public ElaValue GetValue(ElaAsync obj) { if (HasValue(obj)) { return(obj.Return); } else { Wait(Int32.MaxValue, obj); if (!HasValue(obj)) { throw new ElaRuntimeException("AsyncNoValue", "Unable to obtain a value of an async computation."); } return(obj.Return); } }
public bool HasValue(ElaAsync obj) { lock (obj.SyncRoot) return(obj.Return.As <ElaObject>() != null); }
public ElaAsync RunAsync(ElaFunction fun) { var ret = new ElaAsync(this, fun); ret.Run(); return ret; }
public bool HasValue(ElaAsync obj) { lock (obj.SyncRoot) return obj.Return.As<ElaObject>() != null; }
public ElaUnit Wait(int timeout, ElaAsync obj) { var th = obj.Thread; if (th != null) { if (th.Join(timeout)) { lock (syncRoot) { Threads.Remove(th); obj.Thread = null; } } } return ElaUnit.Instance; }