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

Fix Darwin implementation of RunEventLoop to return when StopEventLoopTask is called. #7854

Merged
merged 1 commit into from
Jun 23, 2021

Conversation

bzbarsky-apple
Copy link
Contributor

Problem

Darwin impl of RunEventLoop never returns, even if a task calls StopEventLoopTask.

Change overview

  1. Document the PlatformManager API a bit better.
  2. Fix Darwin implementation to align with the documentation.

Testing

  • Added some unit tests for the defined behavior.
  • Ensured that basic tests in ./scripts/tests/test_suites.sh pass.

CHIP_ERROR err = PlatformMgr().InitChipStack();
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

err = PlatformMgr().StartEventLoopTask();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any way to actually prove from a testability standpoint the difference in behavior here vs. calling RunEventLoop?

i.e show that it returns, but still continues to do work on a separable execution context.

e.g

 CHIP_ERROR err = PlatformMgr().InitChipStack();
 NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

PlatformMgr().ScheduleWork(DidWorkFunc);

NL_TEST_ASSERT(inSuite, DidWorkCheck == false);

PlatformMgr().StartEventLoopTask();

// setup a cond var that gets signaled by the function above, but times out after a while

err = PlatformMgr().StopEventLoopTask();

...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we could probably do something like that. I ran out of time to add more interesting tests here this morning, but would be very much in favor of more of that happening!

@woody-apple woody-apple merged commit ceff3d7 into project-chip:master Jun 23, 2021
@bzbarsky-apple bzbarsky-apple deleted the fix-run-event-loop branch June 23, 2021 21:28
nikita-s-wrk pushed a commit to nikita-s-wrk/connectedhomeip that referenced this pull request Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants