-
Notifications
You must be signed in to change notification settings - Fork 141
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
[ENH, MAINT] MNE Scan: Separating plugins and threads. #883
Open
gabrielbmotta
wants to merge
13
commits into
mne-tools:main
Choose a base branch
from
gabrielbmotta:thread
base: main
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
Codecov Report
@@ Coverage Diff @@
## main #883 +/- ##
==========================================
+ Coverage 30.20% 37.09% +6.89%
==========================================
Files 452 195 -257
Lines 39208 11545 -27663
==========================================
- Hits 11841 4283 -7558
+ Misses 27367 7262 -20105 |
gabrielbmotta
changed the title
WIP [ENH, MAINT] MNE Scan: Separating plugins and threads.
[ENH, MAINT] MNE Scan: Separating plugins and threads.
Jan 27, 2022
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.
Currently plugins are threads by virtue of the thread base class (All plugins inherit from either Sensor of Algorithm plugins, which in turn inherit from Abstract, which is, in main, subclassed from QThread). Currently this leads to a mental model of a plugins that is a single execution thread when 'start' is called. This is already not the case for the sensor plugins, which rely on 'Producer' objects that are on separate threads.
In an effort to limit our use of Qt to UI, this PR gets rid of the QThread subclassing and replaces it with uses of std::thread (to favor composition over inheritance: plugins have threads).
So far only the FiffSimulator plugin and Averaging plugins have been 'converted.'; I've only replaced the thread that previously existed by inheriting from QThread. I wanted to get a sense of what everyone thought of this, and what the new standardized way of doing threading should be.In main, sensor plugins typically have a Producer class: which is also either a subclass of Thread or live in a separate Thread, The 'Producer' QThread could likewise be eliminated, either by likewise refactoring the class to use composition over inheritance and running it's run() in a separate thread, or the class could be eliminated completely by simply having that functionality be performed by a function in the main class, with the plugin having multiple threads as needed, with a function for each main loop, as necessary.