Skip to content

Commit

Permalink
Refactor some of the send / receive logic
Browse files Browse the repository at this point in the history
References #21
  • Loading branch information
andreashuber-lawo committed Apr 26, 2016
1 parent e262531 commit b18891d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Lawo.EmberPlusSharp/Model/Consumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ private async void ReceiveLoop()
{
while (true)
{
await this.WaitForAndApplyChanges();
await this.WaitForAndApplyProviderChangesAsync();
await this.RetrieveChildrenAsync();
}
}
Expand Down Expand Up @@ -320,9 +320,7 @@ private async void AutoSendLoop()
{
while (true)
{
await this.hasChangesSetSource.Task;
await this.DelayAutoSend();
this.hasChangesSetSource = new TaskCompletionSource<bool>();
await this.WaitForLocalChangesAsync();
await this.SendAsync();
}

Expand All @@ -343,15 +341,22 @@ private async void AutoSendLoop()
}
}

private async Task WaitForLocalChangesAsync()
{
await this.hasChangesSetSource.Task;
await this.DelayAutoSend();
this.hasChangesSetSource = new TaskCompletionSource<bool>();
}

private async Task RetrieveChildrenCoreAsync()
{
while (await this.SendRequestAsync())
{
await this.WaitForAndApplyChanges();
await this.WaitForAndApplyProviderChangesAsync();
}
}

private async Task WaitForAndApplyChanges()
private async Task WaitForAndApplyProviderChangesAsync()
{
await this.receiveQueue.WaitForMessageAsync();

Expand Down

0 comments on commit b18891d

Please sign in to comment.