Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Messages will be consumed when the side channel registers #3573

Merged
merged 3 commits into from Mar 5, 2020

Conversation

vincentpierre
Copy link
Contributor

Proposed change(s)

Messages will be consumed when the side channel registers

Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)

Types of change(s)

  • Bug fix
  • New feature
  • Code refactor
  • Breaking change
  • Documentation update
  • Other (please describe)

Checklist

  • Added tests that prove my fix is effective or that my feature works
  • Updated the changelog (if applicable)
  • Updated the documentation (if applicable)
  • Updated the migration guide (if applicable)

Other comments

@vincentpierre vincentpierre self-assigned this Mar 5, 2020
@@ -504,6 +504,19 @@ public void RegisterSideChannel(SideChannel sideChannel)
"A side channel with type index {0} is already registered. You cannot register multiple " +
"side channels of the same id.", channelId));
}

for (int i = 0; i< m_CachedMessages.Count; i++)
Copy link
Contributor

Choose a reason for hiding this comment

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

I need to think about this more, but you might need to save m_CachedMessages.Count at the start of the loop since it can decrease as you iterate.

For example, I think if you have 2 cached messages that match the channel ID, you'll only process 1 - the second time through the loop, i and m_CachedMessages.Count will both be 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Arg ! I did not think of that. You are right, the number should be fixed before the loop

Copy link
Contributor

Choose a reason for hiding this comment

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

In general, I get scared about iterating over a data structure while modifying it. I think freezing the count outside the loop will be safe though.

Co-Authored-By: Chris Elion <chris.elion@unity3d.com>
@vincentpierre vincentpierre merged commit aea515e into master Mar 5, 2020
@delete-merged-branch delete-merged-branch bot deleted the develop-side-channel-reset branch March 5, 2020 20:12
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants