private Task <T> RequestAsync <T>(PID target, object message, FutureProcess <T> future) { var messageEnvelope = new MessageEnvelope(message, future.Pid, null); SendUserMessage(target, messageEnvelope); return(future.Task); }
/// <summary> PoisonAsync will tell and wait actor to stop after processing current user messages in mailbox. </summary> public Task PoisonAsync() { var future = new FutureProcess <object>(); SendSystemMessage(new Watch(future.Pid)); Poison(); return(future.Task); }
public Task <T> RequestAsync <T>(object message) { var tsc = new TaskCompletionSource <T>(); var reff = new FutureProcess <T>(tsc); var name = ProcessRegistry.Instance.NextId(); var(pid, absent) = ProcessRegistry.Instance.TryAdd(name, reff); if (!absent) { throw new ProcessNameExistException(name); } Request(message, pid); return(tsc.Task); }
internal static async Task <T> RequestAsync <T>(this ISenderContext self, PID target, object message, CancellationToken cancellationToken) { using var future = new FutureProcess(self.System); var messageEnvelope = new MessageEnvelope(message, future.Pid); self.Send(target, messageEnvelope); var result = await future.GetTask(cancellationToken); switch (result) { case DeadLetterResponse: throw new DeadLetterException(target); case null: case T: return((T)result !); default: throw new InvalidOperationException( $"Unexpected message. Was type {result.GetType()} but expected {typeof(T)}" ); } }
private Task <T> RequestAsync <T>(object message, FutureProcess <T> future) { Request(message, future.Pid); return(future.Task); }
private Task <T> RequestAsync <T>(PID target, object message, FutureProcess <T> future) { SendUserMessage(target, message, future.PID); return(future.Task); }