当前位置: 首页>>代码示例>>C#>>正文


C# Routing.Routee类代码示例

本文整理汇总了C#中Akka.Routing.Routee的典型用法代码示例。如果您正苦于以下问题:C# Routee类的具体用法?C# Routee怎么用?C# Routee使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Routee类属于Akka.Routing命名空间,在下文中一共展示了Routee类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TailChoppingRoutee

 /// <summary>
 /// Initializes a new instance of the <see cref="TailChoppingRoutee"/> class.
 /// </summary>
 /// <param name="routees">The list of routees that the router uses to send messages.</param>
 /// <param name="within">The time within which at least one response is expected.</param>
 /// <param name="interval">The duration after which the next routee will be picked.</param>
 /// <param name="scheduler">The <see cref="IScheduler"/> used to force deadlines.</param>
 public TailChoppingRoutee(Routee[] routees, TimeSpan within, TimeSpan interval, IScheduler scheduler)
 {
     _routees = routees;
     _within = within;
     _interval = interval;
     _scheduler = scheduler;
 }
开发者ID:juergenhoetzel,项目名称:akka.net,代码行数:14,代码来源:TailChoppingRoutingLogic.cs

示例2: SelectNext

        private Routee SelectNext(Routee[] routees)
        {
            var winningScore = long.MaxValue;

            // round robin fallback
            var winner = routees[(Interlocked.Increment(ref _next) & int.MaxValue) %  routees.Length];

            for (int i = 0; i < routees.Length; i++)
            {
                var routee = routees[i];
                var cell = TryGetActorCell(routee);
                if (cell != null)
                {
                    // routee can be reasoned about it's mailbox size
                    var score = cell.NumberOfMessages;
                    if (score == 0)
                    {
                        // no messages => instant win    
                        return routee;
                    }

                    if (winningScore > score)
                    {
                        winningScore = score;
                        winner = routee;
                    }
                }
            }

            return winner;
        }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:31,代码来源:SmallestMailbox.cs

示例3: Select

 /// <summary>
 /// Selects all routees and creates a TailChoppingRoutee.
 /// </summary>
 /// <param name="message">The message to use.</param>
 /// <param name="routees">The routees to select from.</param>
 /// <returns>A TailChoppingRoutee to handle the tail chopping routing.</returns>
 public override Routee Select(object message, Routee[] routees)
 {
     if(routees.IsNullOrEmpty())
     {
         return Routee.NoRoutee;
     }
     return new TailChoppingRoutee(routees, _within, _interval, _scheduler);
 }
开发者ID:MaciekLesiczka,项目名称:akka.net,代码行数:14,代码来源:TailChoppingRoutingLogic.cs

示例4: Select

 /// <summary>
 /// Selects the routee for the given message.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="routees">The routees.</param>
 /// <returns>Routee.</returns>
 public override Routee Select(object message, Routee[] routees)
 {
     if (routees == null || routees.Length == 0)
     {
         return Routee.NoRoutee;
     }
     return routees[rnd.Next(routees.Length - 1)%routees.Length];
 }
开发者ID:Badmoonz,项目名称:akka.net,代码行数:14,代码来源:Random.cs

示例5: Select

 /// <summary>
 /// Selects the routee for the given message.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="routees">The routees.</param>
 /// <returns>Routee.</returns>
 public override Routee Select(object message, Routee[] routees)
 {
     if (routees == null || routees.Length == 0)
     {
         return Routee.NoRoutee;
     }
     return routees[ThreadLocalRandom.Current.Next(routees.Length - 1)%routees.Length];
 }
开发者ID:jweimann,项目名称:akka.net,代码行数:14,代码来源:Random.cs

示例6: Select

 public override Routee Select(object message, Routee[] routees)
 {
     if (routees == null || routees.Length == 0)
     {
         return Routee.NoRoutee;
     }
     return new ScatterGatherFirstCompletedRoutees(routees,_within);
 }
开发者ID:ClusterReply,项目名称:akka.net,代码行数:8,代码来源:ScatterGatherFirstCompleted.cs

示例7: Select

 /// <summary>
 /// Picks the next <see cref="Routee"/> in the collection to receive the <paramref name="message"/>.
 /// </summary>
 /// <param name="message">The message that is being routed.</param>
 /// <param name="routees">A collection of routees to choose from when receiving the <paramref name="message"/>.</param>
 /// <returns>A <see cref="Routee" /> that is receives the <paramref name="message"/>.</returns>
 public override Routee Select(object message, Routee[] routees)
 {
     if (routees == null || routees.Length == 0)
     {
         return Routee.NoRoutee;
     }
     return routees[(Interlocked.Increment(ref _next) & int.MaxValue) % routees.Length];
 }
开发者ID:juergenhoetzel,项目名称:akka.net,代码行数:14,代码来源:RoundRobin.cs

示例8: Select

        public override Routee Select(object message, Routee[] routees)
        {
            if (message is ConsistentHashable)
            {
                var hashable = (ConsistentHashable) message;
                int hash = hashable.ConsistentHashKey.GetHashCode();
                return routees[hash%routees.Length];
            }

            throw new NotSupportedException("Only ConsistentHashable messages are supported right now");
        }
开发者ID:Badmoonz,项目名称:akka.net,代码行数:11,代码来源:ConsistentHash.cs

示例9: AddRoutees

 protected void AddRoutees(Routee[] routees)
 {
     foreach(var routee in routees)
     {
         if(routee is ActorRefRoutee)
         {
             var @ref = ((ActorRefRoutee)routee).Actor;
             Watch(@ref);
         }
     }
     _router = _router.WithRoutees(_router.Routees.Concat(routees).ToArray());
 }
开发者ID:ClusterReply,项目名称:akka.net,代码行数:12,代码来源:RoutedActorCell.cs

示例10: AddRoutees

 private void AddRoutees(Routee[] routees)
 {
     foreach (var routee in routees)
     {
         if (routee is ActorRefRoutee)
         {
             var @ref = ((ActorRefRoutee)routee).Actor;
             Watch(@ref);
         }
     }
     Router = Router.WithRoutees(routees);
 }
开发者ID:Badmoonz,项目名称:akka.net,代码行数:12,代码来源:RoutedActorCell.cs

示例11: TryGetActorCell

 private ICell TryGetActorCell(Routee routee)
 {
     var refRoutee = routee as ActorRefRoutee;
     if (refRoutee != null)
     {
         var actorRef = refRoutee.Actor as ActorRefWithCell;
         if (actorRef != null)
         {
             return actorRef.Underlying;
         }
     }
     return null;
 }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:13,代码来源:SmallestMailbox.cs

示例12: Select

 /// <summary>
 /// Picks the next <see cref="Routee"/> in the collection to receive the <paramref name="message"/>.
 /// </summary>
 /// <param name="message">The message that is being routed.</param>
 /// <param name="routees">A collection of routees to choose from when receiving the <paramref name="message"/>.</param>
 /// <returns>A <see cref="Routee" /> that is receives the <paramref name="message"/>.</returns>
 public override Routee Select(object message, Routee[] routees)
 {
     if (routees.Length > 0)
     {
         var size = routees.Length;
         int index = (Interlocked.Increment(ref _next) & int.MaxValue)%size;
         return routees[index < 0 ? size + index - 1 : index];
     }
     else
     {
         return Routee.NoRoutee;
     }
 }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:19,代码来源:RoundRobin.cs

示例13: DefaultResizer_must_use_settings_to_evaluate_capacity

        public void DefaultResizer_must_use_settings_to_evaluate_capacity()
        {
            var resizer = new DefaultResizer(2, 3);
            var c1 = resizer.Capacity(new Routee[] { });
            c1.ShouldBe(2);

            var current = new Routee[]
            {
                new ActorRefRoutee(Sys.ActorOf<ResizerTestActor>()),
                new ActorRefRoutee(Sys.ActorOf<ResizerTestActor>())
            };
            var c2 = resizer.Capacity(current);
            c2.ShouldBe(0);
        }
开发者ID:ClusterReply,项目名称:akka.net,代码行数:14,代码来源:ResizerSpec.cs

示例14: ScatterGatherFirstCompletedRoutees

 public ScatterGatherFirstCompletedRoutees(Routee[] routees, TimeSpan within)
 {
     _routees = routees;
     _within = within;
 }
开发者ID:ClusterReply,项目名称:akka.net,代码行数:5,代码来源:ScatterGatherFirstCompleted.cs

示例15: Select

 public override Routee Select(object message, Routee[] routees)
 {
     if (routees == null || !routees.Any())
         return Routee.NoRoutee;
     return new SeveralRoutees(routees);
 }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:6,代码来源:Broadcast.cs


注:本文中的Akka.Routing.Routee类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。