-
Notifications
You must be signed in to change notification settings - Fork 131
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
Introduce optional javascript semantics for event handling #418
Open
tballmsft
wants to merge
36
commits into
master
Choose a base branch
from
js-event-semantics
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- new CONFIG option now allows the user to choose between ordered, serial processing of event handlers and parallel execution of events (JS semantics) OR parallel processing of event handlers and serial execution of events (legacy mciro:bit semantics) - Introduciton of a MicroBitLock primitive for mutual exclusion
guys - can you please merge this work into master? |
- First character of string is now printed on next frame update, rather than waiting for an inter-character gap - No unecessary delay after the final character is printed. These changes make the print() semantics align with the image animate() semantics.
Align fork-on-block implementation of fiber_wake_on_event() with that of fiber_sleep() and MicroBitLock::wait(). This patch has no impact on external behaviour, but introduces a consistent deisgn pattern for fork-on-block handling within the scheduler.
Updated parameters of this internal method to pass the event being processed by value, rather than by reference. This is important for applications using the MESSAGE_BUS_CONCURRENT_EVENTS concurrency mode (JavaScript semantics) to ensure that any multiple event handlers registered for the same event maintain a persistent copy of that event on the relevant fiber stack.
Update to the internal MicroBitDisplay::waitForFreeDisplay() method to ensure that fibers queued waiting for access to the display always re-contest for access, thereby avoiding potnetial race conditions.
@@ -108,7 +108,7 @@ class MicroBitMessageBus : public EventModel, public MicroBitComponent | |||
* @note It is recommended that all external code uses the send() function instead of this function, | |||
* or the constructors provided by MicrobitEvent. | |||
*/ | |||
int process(MicroBitEvent &evt, bool urgent = false); | |||
int process(MicroBitEvent evt, bool urgent = false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@finneyj what's the overhead implications of this change?
Stack sizes will be a few bytes larger, and there'll be one more copy operation during top level processing of each event raise, so a few more microseconds. |
- Replace doubly linked list of Fibers with singly-linked equivalent to reduce memory footprint.
- Create a new FiberTable structure, that record all active fibers - Update fiber creation/deletion code to maintain the table - Add a utility function to allow read access to the table - Introduce a CONFIG option to define the initial FiberTable size
- Add new CONFIG option to enable per-fiber meta data (default: disabled) - Add (void *) pointer to Fiber struct when CONFIG option enabled - Add Yotta CONFIG glue - Refactor fork-on-block handling into a unified function - Align validation semantics of both flavours of invoke() function
- Replace accidentally deleted validation check in fiber_sleep().
- Remove FiberTable structure - Remove CONFIG options and mappings relating to table size - Add new list linkage to Fiber structure to maintain list of all Fibers - Replace get_fiber_table() with get_fiber_list()
Also port from codal-core in support of PXT GC. Also, fix compiler optimization bug in calloc().
- new CONFIG option now allows the user to choose between ordered, serial processing of event handlers and parallel execution of events (JS semantics) OR parallel processing of event handlers and serial execution of events (legacy mciro:bit semantics) - Introduciton of a MicroBitLock primitive for mutual exclusion
- First character of string is now printed on next frame update, rather than waiting for an inter-character gap - No unecessary delay after the final character is printed. These changes make the print() semantics align with the image animate() semantics.
Updated parameters of this internal method to pass the event being processed by value, rather than by reference. This is important for applications using the MESSAGE_BUS_CONCURRENT_EVENTS concurrency mode (JavaScript semantics) to ensure that any multiple event handlers registered for the same event maintain a persistent copy of that event on the relevant fiber stack.
Update to the internal MicroBitDisplay::waitForFreeDisplay() method to ensure that fibers queued waiting for access to the display always re-contest for access, thereby avoiding potnetial race conditions.
…-university/microbit-dal into js-event-semantics
This is port of relevant codal changes in support of GC in the PXT runtime. Also, limit the number of fibers in pool to 3.
Also port from codal-core in support of PXT GC. Also, fix compiler optimization bug in calloc().
- Rename pointers in Fiber struct to be more intuitive.
- Remove redundant API - superceded by get_fiber_list()
- Update component ID values to align with those used in CODAL - Just enables some code cleanup within MakeCode.
- MicroBitSerial use wake_on_event for condition synchronisation. - By contract, a fiber doing this should subsequently call schedule() and no other blocking operation
- Simplify behaviour of print() and printAsync() methods. - print(char) print(ManagedString) and print(MicroBitImage) now all have same semantics: - If provided, the delay parameter is always respected. Screen is cleared after that time. - discrete print operations (character, string of length 1 and MicroBitImage) with no delay parameter are printed, and return immeditely. The screen is not cleared. - print (string of length > 1) with no delay parameter defaults to a delay of MICROBIT_DEFAULT_PRINT_SPEED milliseconds. The screen is cleared on completion.
- fix regression in semantics - all print() operation of unit length now leave the screen uncleared, even when a duration is provided.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
new CONFIG option now allows the user to choose between ordered, serial
processing of event handlers and parallel execution of events (JS
semantics) OR parallel processing of event handlers and serial execution of
events (legacy mciro:bit semantics)
Introduciton of a MicroBitLock primitive for mutual exclusion