internal Chan <T> GetOrCreate <T>() where T : struct { lock (lockObj) { var type = typeof(T); if (chs.ContainsKey(type)) { return((Chan <T>)chs[type]); } chs[type] = new Chan <T>(); return((Chan <T>)chs[type]); } }
public WaitResultInstruction() { var ch = Chan <T> .Make(); ch.Receive( (result, ok) => { if (ok) { _result = result; } _keepWaiting = false; } ); }
internal bool IsExists <T>(out Chan <T> ch) where T : struct { lock (lockObj) { var type = typeof(T); if (chs.ContainsKey(type)) { ch = (Chan <T>)chs[type]; return(true); } ch = null; return(false); } }
public ForInstruction(Action <T> onReceive) { var ch = Chan <T> .Make(); ch.Receive( (t, ok) => { if (!ok) { _keepWaiting = false; return; } onReceive(t); } ); }