Improve initial state transfer locking

This commit is contained in:
Frank A. Krueger 2017-11-15 21:58:48 -06:00
parent 6ec5bbe5a3
commit d63d7e7ffc
1 changed files with 20 additions and 14 deletions

View File

@ -573,8 +573,15 @@ namespace Ooui
void QueueStateMessagesLocked (EventTarget target) void QueueStateMessagesLocked (EventTarget target)
{ {
if (target == null) return; if (target == null) return;
var created = false;
foreach (var m in target.StateMessages) { foreach (var m in target.StateMessages) {
QueueMessageLocked (m); if (m.MessageType == MessageType.Create) {
createdIds.Add (m.TargetId);
created = true;
}
if (created) {
QueueMessageLocked (m);
}
} }
} }
@ -583,24 +590,23 @@ namespace Ooui
// //
// Make sure all the referenced objects have been created // Make sure all the referenced objects have been created
// //
if (message.MessageType == MessageType.Create) { if (!createdIds.Contains (message.TargetId)) {
createdIds.Add (message.TargetId); QueueStateMessagesLocked (element.GetElementById (message.TargetId));
} }
else { if (message.Value is EventTarget ve) {
if (!createdIds.Contains (message.TargetId)) { if (!createdIds.Contains (ve.Id)) {
createdIds.Add (message.TargetId); QueueStateMessagesLocked (ve);
QueueStateMessagesLocked (element.GetElementById (message.TargetId));
} }
if (message.Value is Array a) { }
for (var i = 0; i < a.Length; i++) { else if (message.Value is Array a) {
// Console.WriteLine ($"A{i} = {a.GetValue(i)}"); for (var i = 0; i < a.Length; i++) {
if (a.GetValue (i) is EventTarget e && !createdIds.Contains (e.Id)) { // Console.WriteLine ($"A{i} = {a.GetValue(i)}");
createdIds.Add (e.Id); if (a.GetValue (i) is EventTarget e && !createdIds.Contains (e.Id)) {
QueueStateMessagesLocked (e); QueueStateMessagesLocked (e);
}
} }
} }
} }
// //
// Add it to the queue // Add it to the queue
// //