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

[ENH, MAINT] MNE Scan: Separating plugins and threads. #883

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

gabrielbmotta
Copy link
Collaborator

@gabrielbmotta gabrielbmotta commented Jan 24, 2022

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.

@codecov
Copy link

codecov bot commented Jan 24, 2022

Codecov Report

Merging #883 (2ad5e69) into main (bd31738) will increase coverage by 6.89%.
The diff coverage is n/a.

❗ Current head 2ad5e69 differs from pull request most recent head 9a47404. Consider uploading reports for the commit 9a47404 to get more accurate results

Impacted file tree graph

@@            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     

see 281 files with indirect coverage changes

@gabrielbmotta 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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant