コード例 #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 static object TypedActorEntryPoint(IActorRuntime runtime)
        {
            var mailbox = runtime.CurrentMailbox();

            ITypedActor typedActor = (ITypedActor)mailbox.Receive();

            while (true)
            {
                var msg = (ICallable)mailbox.Receive();
                msg.Call(typedActor);
            }
        }