Added load balancer which prefers actors with small mailboxes (discussed on mailing list a while ago).
This commit is contained in:
parent
c110b86b5c
commit
647bb9cc41
3 changed files with 44 additions and 1 deletions
|
|
@ -73,4 +73,15 @@ class CyclicIterator[T](items: List[T]) extends InfiniteIterator[T] {
|
|||
current = nc.tail
|
||||
nc.head
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SmallestMailboxFirstIterator(items : List[Actor]) extends InfiniteIterator[Actor] {
|
||||
def hasNext = items != Nil
|
||||
|
||||
def next = {
|
||||
def actorWithSmallestMailbox(a1: Actor, a2: Actor) = {
|
||||
if (a1.mailboxSize < a2.mailboxSize) a1 else a2
|
||||
}
|
||||
items.reduceLeft((actor1, actor2) => actorWithSmallestMailbox(actor1,actor2))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue