Skip to content

Conversation

Aaronontheweb
Copy link
Member

close #2308 - realized that this was the result of a weird design choice on my part back when we were working on releasing 1.1. Should never change the priority generator function at runtime. Now it's set via a constructor and is immutable, which should eliminate the issue.

CC @ronnieoverby

@@ -2614,6 +2614,8 @@ namespace Akka.Dispatch.MessageQueues
}
public class UnboundedPriorityMessageQueue : Akka.Dispatch.MessageQueues.BlockingMessageQueue
{
[System.ObsoleteAttribute("Use UnboundedPriorityMessageQueue(Func<object, int> priorityGenerator, int initia" +
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marked all of the methods that don't have you explicitly set the priorityGenerator at construction time as obsolete.

@@ -4853,14 +4855,17 @@ namespace Akka.Util
public override bool IsRight { get; }
public TA Value { get; }
}
public class ListPriorityQueue
public sealed class ListPriorityQueue
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no really means for extending this queue given that all of the important parts of it are private fields.

@@ -12,63 +12,63 @@
namespace Akka.Dispatch.MessageQueues
{
/// <summary>
/// Base class message queue that uses a priority generator for messages
/// Base class for a message queue that uses a priority generator for messages
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to fill in all of the TBDs that @sean-gilliam left as placeholders.

{
_data = new List<Envelope>(initialCapacity);
_priorityCalculator = priorityCalculator;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set all of the guts of the priority queue in the same place...

{
_prioQueue.SetPriorityCalculator(priorityGenerator);
_prioQueue = new ListPriorityQueue(initialCapacity, priorityGenerator);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the key fix: create the queue WITH its priority generator at the same time and never change it again. That way we don't end up in a situation where the mailbox is having messages queued into it while the underlying priority generator is being changed concurrently on another thread.

@Danthar Danthar merged commit b8ed9aa into akkadotnet:dev Jan 12, 2017
@Aaronontheweb Aaronontheweb modified the milestone: 1.1.3 Jan 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UnboundedPriorityMailbox's PriorityGenerator only called sometimes
2 participants