System.disableUpdates() operates asynchronously #1801
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR will be cherry-picked into another PR based on
release/1.2.1
(for 1.2.1-rc.3).Problem
For a full description see the clubhouse story. In a nutshell, System.disableUpdates() should not block the application thread to send the event to the cloud.
Solution
The internal function
system_send_event
gains an additional flag to indicate the event should be processed asynchronously. This is a temporary solution until we introduce futures to all synchronous system APIs so that they may be used synchronously or asynchronously as chosen by the caller.Steps to Test
Testing was done by using the app below both with and without the asynchornous event flag handling. The connection to the cloud was interrupted by turning off the mobile hotspot and the LED observed to see if the application thread continued running. Without asynchronous events, the LED stopped blinking immediately. With asynchronous events, it continued blinking for a few seconds (blocking on queuing the asynchronous request to the system event queue - we should consider allowing the queue to allocate more resources or make some functions optional when the queue cannot accept more items.)
Example App
References
Completeness