コード例 #1
0
        public ActorTaskCompletionSource(IActorRuntime r, ITypedActorRuntime typedRuntime)
        {
            runtime = r;

            Task = runtime.StartNew(() =>
            {
                TaskCompletionSourceHelper.Msg res =
                    (TaskCompletionSourceHelper.Msg)
                    runtime.CurrentMailbox().Receive();

                if (res.state == TaskStatus.Canceled)
                {
                    runtime.CancelSelf();
                }

                if (res.state == TaskStatus.Faulted)
                {
                    throw res.exception;
                }

                return((T)res.result);
            });

            source =
                typedRuntime.Create <ITaskCompletionSource>(
                    new TaskCompletionSourceHelper(runtime, runtime.MailboxFromTask(Task), Task));
        }
コード例 #2
0
        public T CreateTask <T, TResult>(T typedActorInstance, out Task <TResult> task, string name = null)
            where T : ITypedActor
        {
            task = actorRuntime.StartNew(() =>
            {
                TypedActorEntryPoint(actorRuntime);
                return(default(TResult));
            });

            var mailbox =
                actorRuntime.MailboxFromTask(task);

            mailbox.Send(typedActorInstance);
            return(GetOrCreateProxy <T>(mailbox));
        }