Ejemplo n.º 1
0
        void GenerateImplementation(StringBuilder src, List <Assembly> references)
        {
            GenerateAttributes(src);

            var reentrant = ReentrantAttribute.IsReentrant(actor);

            if (reentrant)
            {
                src.AppendLine($"[global::{typeof(Orleans.Concurrency.ReentrantAttribute).FullName}]");
            }

            var mayInterleave = ReentrantAttribute.MayInterleavePredicate(actor) != null;

            if (mayInterleave)
            {
                src.AppendLine("[MayInterleave(\"MayInterleave\")]");
            }

            string impl = $"Orleankka.Core.ActorEndpoint<I{clazz}>";

            if (IsStateful())
            {
                var stateType         = GetStateArgument();
                var stateTypeFullName = stateType.FullName.Replace("+", ".");
                impl = $"Orleankka.Core.StatefulActorEndpoint<I{clazz}, global::{stateTypeFullName}>";
                references.Add(stateType.Assembly);
            }

            src.AppendLine($"public class {clazz} : global::{impl}, I{clazz} {{");
            src.AppendLine($"public static bool MayInterleave(InvokeMethodRequest req) => type.MayInterleave(req);");
            src.AppendLine("}");
        }
Ejemplo n.º 2
0
        internal ActorType(Type actor, Type endpoint)
        {
            this.actor = actor;

            Name             = ActorTypeName.Of(actor);
            Sticky           = StickyAttribute.IsApplied(actor);
            keepAliveTimeout = Sticky ? TimeSpan.FromDays(365 * 10) : KeepAliveAttribute.Timeout(actor);
            Invoker          = InvocationPipeline.Instance.GetInvoker(actor, InvokerAttribute.From(actor));

            interleavePredicate = ReentrantAttribute.MayInterleavePredicate(actor);

            dispatcher = new Dispatcher(actor);
            dispatchers.Add(actor, dispatcher);

            Init(endpoint);
        }