com.wallstop-studios.dxmessaging 2.0.0-rc09 → 2.0.0-rc11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,12 +17,12 @@ This project has a dependency on my [`Unity Helpers`](https://github.com/wallsto
17
17
  DxMessaging is currently a bit slower (2-3x) than Unity's built in messaging solution (when running in Unity). [Source](./Tests/Runtime/Benchmarks/PerformanceTests.cs).
18
18
  | Message Tech | Operations / Second |
19
19
  | ------------ | ------------------- |
20
- | Unity | 2,101,721 |
21
- | DxMessaging (GameObject) - Normal | 889,760 |
22
- | DxMessaging (Component) - Normal | 869,437 |
23
- | DxMessaging (GameObject) - No-Copy | 871,880 |
24
- | DxMessaging (Component) - No-Copy | 899,361 |
25
- | DxMessaging (Untargeted) - No-Copy | 1,239,673 |
20
+ | Unity | 2,509,901 |
21
+ | DxMessaging (GameObject) - Normal | 1,031,034 |
22
+ | DxMessaging (Component) - Normal | 1,066,371 |
23
+ | DxMessaging (GameObject) - No-Copy | 1,001,639 |
24
+ | DxMessaging (Component) - No-Copy | 1,080,738 |
25
+ | DxMessaging (Untargeted) - No-Copy | 1,389,542 |
26
26
 
27
27
  # Functionality
28
28
  While not as fast, DxMessaging offers *additional functionality* as compared to Unity's messaging solution.
@@ -33,42 +33,39 @@
33
33
 
34
34
  public RegistrationLog Log => _log;
35
35
 
36
+ private readonly Dictionary<Type, SortedList<int, SortedList<MessageHandler, int>>> _sinks =
37
+ new();
36
38
  private readonly Dictionary<
37
39
  Type,
38
- SortedDictionary<int, Dictionary<MessageHandler, int>>
39
- > _sinks = new();
40
- private readonly Dictionary<
41
- Type,
42
- Dictionary<InstanceId, SortedDictionary<int, Dictionary<MessageHandler, int>>>
40
+ Dictionary<InstanceId, SortedList<int, SortedList<MessageHandler, int>>>
43
41
  > _targetedSinks = new();
44
42
 
45
43
  private readonly Dictionary<
46
44
  Type,
47
- Dictionary<InstanceId, SortedDictionary<int, Dictionary<MessageHandler, int>>>
45
+ Dictionary<InstanceId, SortedList<int, SortedList<MessageHandler, int>>>
48
46
  > _broadcastSinks = new();
49
47
  private readonly Dictionary<
50
48
  Type,
51
- SortedDictionary<int, Dictionary<MessageHandler, int>>
49
+ SortedList<int, SortedList<MessageHandler, int>>
52
50
  > _postProcessingSinks = new();
53
51
  private readonly Dictionary<
54
52
  Type,
55
- Dictionary<InstanceId, SortedDictionary<int, Dictionary<MessageHandler, int>>>
53
+ Dictionary<InstanceId, SortedList<int, SortedList<MessageHandler, int>>>
56
54
  > _postProcessingTargetedSinks = new();
57
55
  private readonly Dictionary<
58
56
  Type,
59
- Dictionary<InstanceId, SortedDictionary<int, Dictionary<MessageHandler, int>>>
57
+ Dictionary<InstanceId, SortedList<int, SortedList<MessageHandler, int>>>
60
58
  > _postProcessingBroadcastSinks = new();
61
59
  private readonly Dictionary<
62
60
  Type,
63
- SortedDictionary<int, Dictionary<MessageHandler, int>>
61
+ SortedList<int, SortedList<MessageHandler, int>>
64
62
  > _postProcessingTargetedWithoutTargetingSinks = new();
65
63
  private readonly Dictionary<
66
64
  Type,
67
- SortedDictionary<int, Dictionary<MessageHandler, int>>
65
+ SortedList<int, SortedList<MessageHandler, int>>
68
66
  > _postProcessingBroadcastWithoutSourceSinks = new();
69
- private readonly Dictionary<MessageHandler, int> _globalSinks = new();
70
- private readonly Dictionary<Type, SortedDictionary<int, List<object>>> _interceptsByType =
71
- new();
67
+ private readonly SortedList<MessageHandler, int> _globalSinks = new();
68
+ private readonly Dictionary<Type, SortedList<int, List<object>>> _interceptsByType = new();
72
69
  private readonly Dictionary<object, Dictionary<int, int>> _uniqueInterceptorsAndPriorities =
73
70
  new();
74
71
 
@@ -79,7 +76,7 @@
79
76
  // These are used so we aren't allocating as much every time we send messages
80
77
  private readonly Stack<List<MessageHandler>> _messageHandlers = new();
81
78
  private readonly Stack<
82
- List<KeyValuePair<int, Dictionary<MessageHandler, int>>>
79
+ List<KeyValuePair<int, SortedList<MessageHandler, int>>>
83
80
  > _sortedHandlers = new();
84
81
  private readonly Stack<List<List<object>>> _interceptors = new();
85
82
  private readonly Stack<List<object>> _innerInterceptorsStack = new();
@@ -309,11 +306,11 @@
309
306
  if (
310
307
  !_interceptsByType.TryGetValue(
311
308
  type,
312
- out SortedDictionary<int, List<object>> prioritizedInterceptors
309
+ out SortedList<int, List<object>> prioritizedInterceptors
313
310
  )
314
311
  )
315
312
  {
316
- prioritizedInterceptors = new SortedDictionary<int, List<object>>();
313
+ prioritizedInterceptors = new SortedList<int, List<object>>();
317
314
  _interceptsByType[type] = prioritizedInterceptors;
318
315
  }
319
316
 
@@ -461,7 +458,7 @@
461
458
  if (
462
459
  _postProcessingSinks.TryGetValue(
463
460
  type,
464
- out SortedDictionary<int, Dictionary<MessageHandler, int>> sortedHandlers
461
+ out SortedList<int, SortedList<MessageHandler, int>> sortedHandlers
465
462
  )
466
463
  && 0 < sortedHandlers.Count
467
464
  )
@@ -469,18 +466,18 @@
469
466
  foundAnyHandlers = true;
470
467
  if (sortedHandlers.Count == 1)
471
468
  {
472
- KeyValuePair<int, Dictionary<MessageHandler, int>> entry =
469
+ KeyValuePair<int, SortedList<MessageHandler, int>> entry =
473
470
  sortedHandlers.First();
474
471
  RunUntargetedPostProcessing(ref typedMessage, entry.Key, entry.Value);
475
472
  }
476
473
  else
477
474
  {
478
- List<KeyValuePair<int, Dictionary<MessageHandler, int>>> handlerList =
475
+ List<KeyValuePair<int, SortedList<MessageHandler, int>>> handlerList =
479
476
  GetOrAddMessageHandlerStack(sortedHandlers);
480
477
  try
481
478
  {
482
479
  foreach (
483
- KeyValuePair<int, Dictionary<MessageHandler, int>> entry in handlerList
480
+ KeyValuePair<int, SortedList<MessageHandler, int>> entry in handlerList
484
481
  )
485
482
  {
486
483
  RunUntargetedPostProcessing(ref typedMessage, entry.Key, entry.Value);
@@ -506,7 +503,7 @@
506
503
  private void RunUntargetedPostProcessing<TMessage>(
507
504
  ref TMessage typedMessage,
508
505
  int priority,
509
- Dictionary<MessageHandler, int> handlers
506
+ SortedList<MessageHandler, int> handlers
510
507
  )
511
508
  where TMessage : IUntargetedMessage
512
509
  {
@@ -597,12 +594,12 @@
597
594
  type,
598
595
  out Dictionary<
599
596
  InstanceId,
600
- SortedDictionary<int, Dictionary<MessageHandler, int>>
597
+ SortedList<int, SortedList<MessageHandler, int>>
601
598
  > targetedHandlers
602
599
  )
603
600
  && targetedHandlers.TryGetValue(
604
601
  target,
605
- out SortedDictionary<int, Dictionary<MessageHandler, int>> sortedHandlers
602
+ out SortedList<int, SortedList<MessageHandler, int>> sortedHandlers
606
603
  )
607
604
  && 0 < sortedHandlers.Count
608
605
  )
@@ -610,18 +607,18 @@
610
607
  foundAnyHandlers = true;
611
608
  if (sortedHandlers.Count == 1)
612
609
  {
613
- KeyValuePair<int, Dictionary<MessageHandler, int>> entry =
610
+ KeyValuePair<int, SortedList<MessageHandler, int>> entry =
614
611
  sortedHandlers.First();
615
612
  RunTargetedBroadcast(ref target, ref typedMessage, entry.Key, entry.Value);
616
613
  }
617
614
  else
618
615
  {
619
- List<KeyValuePair<int, Dictionary<MessageHandler, int>>> handlerList =
616
+ List<KeyValuePair<int, SortedList<MessageHandler, int>>> handlerList =
620
617
  GetOrAddMessageHandlerStack(sortedHandlers);
621
618
  try
622
619
  {
623
620
  foreach (
624
- KeyValuePair<int, Dictionary<MessageHandler, int>> entry in handlerList
621
+ KeyValuePair<int, SortedList<MessageHandler, int>> entry in handlerList
625
622
  )
626
623
  {
627
624
  RunTargetedBroadcast(
@@ -650,18 +647,18 @@
650
647
  foundAnyHandlers = true;
651
648
  if (sortedHandlers.Count == 1)
652
649
  {
653
- KeyValuePair<int, Dictionary<MessageHandler, int>> entry =
650
+ KeyValuePair<int, SortedList<MessageHandler, int>> entry =
654
651
  sortedHandlers.First();
655
652
  RunTargetedPostProcessing(ref target, ref typedMessage, entry.Key, entry.Value);
656
653
  }
657
654
  else
658
655
  {
659
- List<KeyValuePair<int, Dictionary<MessageHandler, int>>> handlerList =
656
+ List<KeyValuePair<int, SortedList<MessageHandler, int>>> handlerList =
660
657
  GetOrAddMessageHandlerStack(sortedHandlers);
661
658
  try
662
659
  {
663
660
  foreach (
664
- KeyValuePair<int, Dictionary<MessageHandler, int>> entry in handlerList
661
+ KeyValuePair<int, SortedList<MessageHandler, int>> entry in handlerList
665
662
  )
666
663
  {
667
664
  RunTargetedPostProcessing(
@@ -686,7 +683,7 @@
686
683
  {
687
684
  if (sortedHandlers.Count == 1)
688
685
  {
689
- KeyValuePair<int, Dictionary<MessageHandler, int>> entry =
686
+ KeyValuePair<int, SortedList<MessageHandler, int>> entry =
690
687
  sortedHandlers.First();
691
688
  RunTargetedWithoutTargetingPostProcessing(
692
689
  ref target,
@@ -697,12 +694,12 @@
697
694
  }
698
695
  else
699
696
  {
700
- List<KeyValuePair<int, Dictionary<MessageHandler, int>>> handlerList =
697
+ List<KeyValuePair<int, SortedList<MessageHandler, int>>> handlerList =
701
698
  GetOrAddMessageHandlerStack(sortedHandlers);
702
699
  try
703
700
  {
704
701
  foreach (
705
- KeyValuePair<int, Dictionary<MessageHandler, int>> entry in handlerList
702
+ KeyValuePair<int, SortedList<MessageHandler, int>> entry in handlerList
706
703
  )
707
704
  {
708
705
  RunTargetedWithoutTargetingPostProcessing(
@@ -735,7 +732,7 @@
735
732
  ref InstanceId target,
736
733
  ref TMessage typedMessage,
737
734
  int priority,
738
- Dictionary<MessageHandler, int> handlers
735
+ SortedList<MessageHandler, int> handlers
739
736
  )
740
737
  where TMessage : ITargetedMessage
741
738
  {
@@ -787,7 +784,7 @@
787
784
  ref InstanceId target,
788
785
  ref TMessage typedMessage,
789
786
  int priority,
790
- Dictionary<MessageHandler, int> handlers
787
+ SortedList<MessageHandler, int> handlers
791
788
  )
792
789
  where TMessage : ITargetedMessage
793
790
  {
@@ -839,7 +836,7 @@
839
836
  ref InstanceId target,
840
837
  ref TMessage typedMessage,
841
838
  int priority,
842
- Dictionary<MessageHandler, int> handlers
839
+ SortedList<MessageHandler, int> handlers
843
840
  )
844
841
  where TMessage : ITargetedMessage
845
842
  {
@@ -929,12 +926,12 @@
929
926
  type,
930
927
  out Dictionary<
931
928
  InstanceId,
932
- SortedDictionary<int, Dictionary<MessageHandler, int>>
929
+ SortedList<int, SortedList<MessageHandler, int>>
933
930
  > broadcastHandlers
934
931
  )
935
932
  && broadcastHandlers.TryGetValue(
936
933
  source,
937
- out SortedDictionary<int, Dictionary<MessageHandler, int>> sortedHandlers
934
+ out SortedList<int, SortedList<MessageHandler, int>> sortedHandlers
938
935
  )
939
936
  && 0 < sortedHandlers.Count
940
937
  )
@@ -942,18 +939,18 @@
942
939
  foundAnyHandlers = true;
943
940
  if (sortedHandlers.Count == 1)
944
941
  {
945
- KeyValuePair<int, Dictionary<MessageHandler, int>> entry =
942
+ KeyValuePair<int, SortedList<MessageHandler, int>> entry =
946
943
  sortedHandlers.First();
947
944
  RunBroadcast(ref source, ref typedMessage, entry.Key, entry.Value);
948
945
  }
949
946
  else
950
947
  {
951
- List<KeyValuePair<int, Dictionary<MessageHandler, int>>> handlerList =
948
+ List<KeyValuePair<int, SortedList<MessageHandler, int>>> handlerList =
952
949
  GetOrAddMessageHandlerStack(sortedHandlers);
953
950
  try
954
951
  {
955
952
  foreach (
956
- KeyValuePair<int, Dictionary<MessageHandler, int>> entry in handlerList
953
+ KeyValuePair<int, SortedList<MessageHandler, int>> entry in handlerList
957
954
  )
958
955
  {
959
956
  RunBroadcast(ref source, ref typedMessage, entry.Key, entry.Value);
@@ -977,7 +974,7 @@
977
974
  foundAnyHandlers = true;
978
975
  if (sortedHandlers.Count == 1)
979
976
  {
980
- KeyValuePair<int, Dictionary<MessageHandler, int>> entry =
977
+ KeyValuePair<int, SortedList<MessageHandler, int>> entry =
981
978
  sortedHandlers.First();
982
979
  RunBroadcastPostProcessing(
983
980
  ref source,
@@ -988,12 +985,12 @@
988
985
  }
989
986
  else
990
987
  {
991
- List<KeyValuePair<int, Dictionary<MessageHandler, int>>> handlerList =
988
+ List<KeyValuePair<int, SortedList<MessageHandler, int>>> handlerList =
992
989
  GetOrAddMessageHandlerStack(sortedHandlers);
993
990
  try
994
991
  {
995
992
  foreach (
996
- KeyValuePair<int, Dictionary<MessageHandler, int>> entry in handlerList
993
+ KeyValuePair<int, SortedList<MessageHandler, int>> entry in handlerList
997
994
  )
998
995
  {
999
996
  RunBroadcastPostProcessing(
@@ -1018,7 +1015,7 @@
1018
1015
  {
1019
1016
  if (sortedHandlers.Count == 1)
1020
1017
  {
1021
- KeyValuePair<int, Dictionary<MessageHandler, int>> entry =
1018
+ KeyValuePair<int, SortedList<MessageHandler, int>> entry =
1022
1019
  sortedHandlers.First();
1023
1020
  RunBroadcastWithoutSourcePostProcessing(
1024
1021
  ref source,
@@ -1029,12 +1026,12 @@
1029
1026
  }
1030
1027
  else
1031
1028
  {
1032
- List<KeyValuePair<int, Dictionary<MessageHandler, int>>> handlerList =
1029
+ List<KeyValuePair<int, SortedList<MessageHandler, int>>> handlerList =
1033
1030
  GetOrAddMessageHandlerStack(sortedHandlers);
1034
1031
  try
1035
1032
  {
1036
1033
  foreach (
1037
- KeyValuePair<int, Dictionary<MessageHandler, int>> entry in handlerList
1034
+ KeyValuePair<int, SortedList<MessageHandler, int>> entry in handlerList
1038
1035
  )
1039
1036
  {
1040
1037
  RunBroadcastWithoutSourcePostProcessing(
@@ -1067,7 +1064,7 @@
1067
1064
  ref InstanceId source,
1068
1065
  ref TMessage typedMessage,
1069
1066
  int priority,
1070
- Dictionary<MessageHandler, int> handlers
1067
+ SortedList<MessageHandler, int> handlers
1071
1068
  )
1072
1069
  where TMessage : IBroadcastMessage
1073
1070
  {
@@ -1119,7 +1116,7 @@
1119
1116
  ref InstanceId source,
1120
1117
  ref TMessage typedMessage,
1121
1118
  int priority,
1122
- Dictionary<MessageHandler, int> handlers
1119
+ SortedList<MessageHandler, int> handlers
1123
1120
  )
1124
1121
  where TMessage : IBroadcastMessage
1125
1122
  {
@@ -1171,7 +1168,7 @@
1171
1168
  ref InstanceId source,
1172
1169
  ref TMessage typedMessage,
1173
1170
  int priority,
1174
- Dictionary<MessageHandler, int> handlers
1171
+ SortedList<MessageHandler, int> handlers
1175
1172
  )
1176
1173
  where TMessage : IBroadcastMessage
1177
1174
  {
@@ -1336,10 +1333,7 @@
1336
1333
  )
1337
1334
  {
1338
1335
  if (
1339
- !_interceptsByType.TryGetValue(
1340
- type,
1341
- out SortedDictionary<int, List<object>> interceptors
1342
- )
1336
+ !_interceptsByType.TryGetValue(type, out SortedList<int, List<object>> interceptors)
1343
1337
  || interceptors.Count <= 0
1344
1338
  )
1345
1339
  {
@@ -1504,7 +1498,7 @@
1504
1498
  if (
1505
1499
  !_sinks.TryGetValue(
1506
1500
  type,
1507
- out SortedDictionary<int, Dictionary<MessageHandler, int>> sortedHandlers
1501
+ out SortedList<int, SortedList<MessageHandler, int>> sortedHandlers
1508
1502
  )
1509
1503
  || sortedHandlers.Count <= 0
1510
1504
  )
@@ -1514,16 +1508,16 @@
1514
1508
 
1515
1509
  if (sortedHandlers.Count == 1)
1516
1510
  {
1517
- KeyValuePair<int, Dictionary<MessageHandler, int>> entry = sortedHandlers.First();
1511
+ KeyValuePair<int, SortedList<MessageHandler, int>> entry = sortedHandlers.First();
1518
1512
  RunUntargetedBroadcast(ref message, entry.Key, entry.Value);
1519
1513
  return true;
1520
1514
  }
1521
1515
 
1522
- List<KeyValuePair<int, Dictionary<MessageHandler, int>>> handlerList =
1516
+ List<KeyValuePair<int, SortedList<MessageHandler, int>>> handlerList =
1523
1517
  GetOrAddMessageHandlerStack(sortedHandlers);
1524
1518
  try
1525
1519
  {
1526
- foreach (KeyValuePair<int, Dictionary<MessageHandler, int>> entry in handlerList)
1520
+ foreach (KeyValuePair<int, SortedList<MessageHandler, int>> entry in handlerList)
1527
1521
  {
1528
1522
  RunUntargetedBroadcast(ref message, entry.Key, entry.Value);
1529
1523
  }
@@ -1539,7 +1533,7 @@
1539
1533
  private void RunUntargetedBroadcast<TMessage>(
1540
1534
  ref TMessage message,
1541
1535
  int priority,
1542
- Dictionary<MessageHandler, int> handlers
1536
+ SortedList<MessageHandler, int> handlers
1543
1537
  )
1544
1538
  where TMessage : IMessage
1545
1539
  {
@@ -1587,7 +1581,7 @@
1587
1581
  if (
1588
1582
  !_sinks.TryGetValue(
1589
1583
  type,
1590
- out SortedDictionary<int, Dictionary<MessageHandler, int>> sortedHandlers
1584
+ out SortedList<int, SortedList<MessageHandler, int>> sortedHandlers
1591
1585
  )
1592
1586
  || sortedHandlers.Count <= 0
1593
1587
  )
@@ -1597,16 +1591,16 @@
1597
1591
 
1598
1592
  if (sortedHandlers.Count == 1)
1599
1593
  {
1600
- KeyValuePair<int, Dictionary<MessageHandler, int>> entry = sortedHandlers.First();
1594
+ KeyValuePair<int, SortedList<MessageHandler, int>> entry = sortedHandlers.First();
1601
1595
  RunTargetedWithoutTargeting(ref target, ref message, entry.Key, entry.Value);
1602
1596
  return true;
1603
1597
  }
1604
1598
 
1605
- List<KeyValuePair<int, Dictionary<MessageHandler, int>>> handlerList =
1599
+ List<KeyValuePair<int, SortedList<MessageHandler, int>>> handlerList =
1606
1600
  GetOrAddMessageHandlerStack(sortedHandlers);
1607
1601
  try
1608
1602
  {
1609
- foreach (KeyValuePair<int, Dictionary<MessageHandler, int>> entry in handlerList)
1603
+ foreach (KeyValuePair<int, SortedList<MessageHandler, int>> entry in handlerList)
1610
1604
  {
1611
1605
  RunTargetedWithoutTargeting(ref target, ref message, entry.Key, entry.Value);
1612
1606
  }
@@ -1623,7 +1617,7 @@
1623
1617
  ref InstanceId target,
1624
1618
  ref TMessage message,
1625
1619
  int priority,
1626
- Dictionary<MessageHandler, int> handlers
1620
+ SortedList<MessageHandler, int> handlers
1627
1621
  )
1628
1622
  where TMessage : ITargetedMessage
1629
1623
  {
@@ -1676,7 +1670,7 @@
1676
1670
  if (
1677
1671
  !_sinks.TryGetValue(
1678
1672
  type,
1679
- out SortedDictionary<int, Dictionary<MessageHandler, int>> sortedHandlers
1673
+ out SortedList<int, SortedList<MessageHandler, int>> sortedHandlers
1680
1674
  )
1681
1675
  || sortedHandlers.Count <= 0
1682
1676
  )
@@ -1686,16 +1680,16 @@
1686
1680
 
1687
1681
  if (sortedHandlers.Count == 1)
1688
1682
  {
1689
- KeyValuePair<int, Dictionary<MessageHandler, int>> entry = sortedHandlers.First();
1683
+ KeyValuePair<int, SortedList<MessageHandler, int>> entry = sortedHandlers.First();
1690
1684
  RunBroadcastWithoutSource(ref source, ref message, entry.Key, entry.Value);
1691
1685
  return true;
1692
1686
  }
1693
1687
 
1694
- List<KeyValuePair<int, Dictionary<MessageHandler, int>>> handlerList =
1688
+ List<KeyValuePair<int, SortedList<MessageHandler, int>>> handlerList =
1695
1689
  GetOrAddMessageHandlerStack(sortedHandlers);
1696
1690
  try
1697
1691
  {
1698
- foreach (KeyValuePair<int, Dictionary<MessageHandler, int>> entry in handlerList)
1692
+ foreach (KeyValuePair<int, SortedList<MessageHandler, int>> entry in handlerList)
1699
1693
  {
1700
1694
  RunBroadcastWithoutSource(ref source, ref message, entry.Key, entry.Value);
1701
1695
  }
@@ -1712,7 +1706,7 @@
1712
1706
  ref InstanceId source,
1713
1707
  ref TMessage message,
1714
1708
  int priority,
1715
- Dictionary<MessageHandler, int> handlers
1709
+ SortedList<MessageHandler, int> handlers
1716
1710
  )
1717
1711
  where TMessage : IBroadcastMessage
1718
1712
  {
@@ -1762,7 +1756,7 @@
1762
1756
 
1763
1757
  private Action InternalRegisterUntargeted<T>(
1764
1758
  MessageHandler messageHandler,
1765
- Dictionary<Type, SortedDictionary<int, Dictionary<MessageHandler, int>>> sinks,
1759
+ Dictionary<Type, SortedList<int, SortedList<MessageHandler, int>>> sinks,
1766
1760
  RegistrationMethod registrationMethod,
1767
1761
  int priority
1768
1762
  )
@@ -1779,17 +1773,17 @@
1779
1773
  if (
1780
1774
  !sinks.TryGetValue(
1781
1775
  type,
1782
- out SortedDictionary<int, Dictionary<MessageHandler, int>> handlers
1776
+ out SortedList<int, SortedList<MessageHandler, int>> handlers
1783
1777
  )
1784
1778
  )
1785
1779
  {
1786
- handlers = new SortedDictionary<int, Dictionary<MessageHandler, int>>();
1780
+ handlers = new SortedList<int, SortedList<MessageHandler, int>>();
1787
1781
  sinks[type] = handlers;
1788
1782
  }
1789
1783
 
1790
- if (!handlers.TryGetValue(priority, out Dictionary<MessageHandler, int> handler))
1784
+ if (!handlers.TryGetValue(priority, out SortedList<MessageHandler, int> handler))
1791
1785
  {
1792
- handler = new Dictionary<MessageHandler, int>();
1786
+ handler = new SortedList<MessageHandler, int>();
1793
1787
  handlers[priority] = handler;
1794
1788
  }
1795
1789
 
@@ -1866,7 +1860,7 @@
1866
1860
  MessageHandler messageHandler,
1867
1861
  Dictionary<
1868
1862
  Type,
1869
- Dictionary<InstanceId, SortedDictionary<int, Dictionary<MessageHandler, int>>>
1863
+ Dictionary<InstanceId, SortedList<int, SortedList<MessageHandler, int>>>
1870
1864
  > sinks,
1871
1865
  RegistrationMethod registrationMethod,
1872
1866
  int priority
@@ -1883,33 +1877,30 @@
1883
1877
  type,
1884
1878
  out Dictionary<
1885
1879
  InstanceId,
1886
- SortedDictionary<int, Dictionary<MessageHandler, int>>
1880
+ SortedList<int, SortedList<MessageHandler, int>>
1887
1881
  > broadcastHandlers
1888
1882
  )
1889
1883
  )
1890
1884
  {
1891
1885
  broadcastHandlers =
1892
- new Dictionary<
1893
- InstanceId,
1894
- SortedDictionary<int, Dictionary<MessageHandler, int>>
1895
- >();
1886
+ new Dictionary<InstanceId, SortedList<int, SortedList<MessageHandler, int>>>();
1896
1887
  sinks[type] = broadcastHandlers;
1897
1888
  }
1898
1889
 
1899
1890
  if (
1900
1891
  !broadcastHandlers.TryGetValue(
1901
1892
  context,
1902
- out SortedDictionary<int, Dictionary<MessageHandler, int>> handlers
1893
+ out SortedList<int, SortedList<MessageHandler, int>> handlers
1903
1894
  )
1904
1895
  )
1905
1896
  {
1906
- handlers = new SortedDictionary<int, Dictionary<MessageHandler, int>>();
1897
+ handlers = new SortedList<int, SortedList<MessageHandler, int>>();
1907
1898
  broadcastHandlers[context] = handlers;
1908
1899
  }
1909
1900
 
1910
- if (!handlers.TryGetValue(priority, out Dictionary<MessageHandler, int> handler))
1901
+ if (!handlers.TryGetValue(priority, out SortedList<MessageHandler, int> handler))
1911
1902
  {
1912
- handler = new Dictionary<MessageHandler, int>();
1903
+ handler = new SortedList<MessageHandler, int>();
1913
1904
  handlers[priority] = handler;
1914
1905
  }
1915
1906
 
@@ -1987,18 +1978,18 @@
1987
1978
  }
1988
1979
 
1989
1980
  private List<
1990
- KeyValuePair<int, Dictionary<MessageHandler, int>>
1981
+ KeyValuePair<int, SortedList<MessageHandler, int>>
1991
1982
  > GetOrAddMessageHandlerStack(
1992
- IEnumerable<KeyValuePair<int, Dictionary<MessageHandler, int>>> handlers
1983
+ IEnumerable<KeyValuePair<int, SortedList<MessageHandler, int>>> handlers
1993
1984
  )
1994
1985
  {
1995
1986
  if (
1996
1987
  !_sortedHandlers.TryPop(
1997
- out List<KeyValuePair<int, Dictionary<MessageHandler, int>>> messageHandlers
1988
+ out List<KeyValuePair<int, SortedList<MessageHandler, int>>> messageHandlers
1998
1989
  )
1999
1990
  )
2000
1991
  {
2001
- return new List<KeyValuePair<int, Dictionary<MessageHandler, int>>>(handlers);
1992
+ return new List<KeyValuePair<int, SortedList<MessageHandler, int>>>(handlers);
2002
1993
  }
2003
1994
 
2004
1995
  messageHandlers.Clear();
@@ -12,6 +12,9 @@
12
12
  /// kinds of types to trigger functions that are registered with it.
13
13
  /// </summary>
14
14
  public sealed class MessageHandler
15
+ : IEquatable<MessageHandler>,
16
+ IComparable,
17
+ IComparable<MessageHandler>
15
18
  {
16
19
  public delegate void FastHandler<TMessage>(ref TMessage message)
17
20
  where TMessage : IMessage;
@@ -1220,6 +1223,46 @@
1220
1223
  return (messageBus ?? MessageBus).RegisterTargetedInterceptor(interceptor, priority);
1221
1224
  }
1222
1225
 
1226
+ public override bool Equals(object obj)
1227
+ {
1228
+ return Equals(obj as MessageHandler);
1229
+ }
1230
+
1231
+ public bool Equals(MessageHandler other)
1232
+ {
1233
+ if (other == null)
1234
+ {
1235
+ return false;
1236
+ }
1237
+
1238
+ if (ReferenceEquals(other, this))
1239
+ {
1240
+ return true;
1241
+ }
1242
+
1243
+ return owner.Equals(other.owner);
1244
+ }
1245
+
1246
+ public override int GetHashCode()
1247
+ {
1248
+ return owner.GetHashCode();
1249
+ }
1250
+
1251
+ public int CompareTo(MessageHandler other)
1252
+ {
1253
+ if (other == null)
1254
+ {
1255
+ return -1;
1256
+ }
1257
+
1258
+ return owner.CompareTo(other.owner);
1259
+ }
1260
+
1261
+ public int CompareTo(object obj)
1262
+ {
1263
+ return CompareTo(obj as MessageHandler);
1264
+ }
1265
+
1223
1266
  public override string ToString()
1224
1267
  {
1225
1268
  return new
@@ -1231,7 +1274,7 @@
1231
1274
  .Values.SelectMany(handlers => handlers.Keys)
1232
1275
  .Distinct()
1233
1276
  .Select(type => type.Name)
1234
- .OrderBy(_ => _)
1277
+ .OrderBy(x => x)
1235
1278
  ),
1236
1279
  }.ToString();
1237
1280
  }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.dxmessaging",
3
- "version": "2.0.0-rc09",
3
+ "version": "2.0.0-rc11",
4
4
  "displayName": "DxMessaging",
5
5
  "description": "Synchronous Event Bus for Unity",
6
6
  "unity": "2021.3",
7
7
  "dependencies": {
8
- "com.wallstop-studios.unity-helpers" : "2.0.0-rc13"
8
+ "com.wallstop-studios.unity-helpers" : "2.0.0-rc15"
9
9
  },
10
10
  "keywords": [
11
11
  "messaging",