public void request(Chameneo creature, Action <object> success = null, Action <Exception> failure = null) { var __success = success; var __failure = failure; __enter(() => __advance(__concurrentrequest(creature, __success, __failure).GetEnumerator()), failure); }
public void meet(Chameneo other, Color color, Action <object> success = null, Action <Exception> failure = null) { var __success = success; var __failure = failure; __enter(() => __advance(__concurrentmeet(other, color, __success, __failure).GetEnumerator()), failure); }
private IEnumerable <Expression> __concurrentrequest(Chameneo creature, Action <object> __success, Action <Exception> __failure) { if (_first != null) { //meet, exchange colors, etc var firstColor = _first.Colour; _first.meet(creature, creature.Colour); creature.meet(_first, firstColor); //reset for new pair _first = null; _meetings--; //exit if (_meetings == 0) { Node.Stop(); } } else { _first = creature; } { __dispatch("request"); if (__success != null) { __success(null); } yield break; } }
public Task <object> request(Chameneo creature, bool async) { if (!async) { throw new InvalidOperationException("use async: true"); } var completion = new TaskCompletionSource <object>(); Action <object> __success = (__res) => completion.SetResult((object)__res); Action <Exception> __failure = (__ex) => completion.SetException(__ex); __enter(() => __advance(__concurrentrequest(creature, __success, __failure).GetEnumerator()), __failure); return(completion.Task); }
private IEnumerable <Expression> __concurrentmeet(Chameneo other, Color color, Action <object> __success, Action <Exception> __failure) { Colour = compliment(Colour, color); Meetings++; if (other == this) { MeetingsWithSelf++; } { __dispatch("meet"); if (__success != null) { __success(null); } yield break; } }