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

Base threadloop off of ManagedThread #220

Open
4 of 6 tasks
charmoniumQ opened this issue Jan 24, 2021 · 0 comments
Open
4 of 6 tasks

Base threadloop off of ManagedThread #220

charmoniumQ opened this issue Jan 24, 2021 · 0 comments
Assignees
Labels
plumbing Something that connects/interfaces/plugs into many parts of ILLIXR.

Comments

@charmoniumQ
Copy link
Member

charmoniumQ commented Jan 24, 2021

All threads that run a tight-loop and check for termination in ILLIXR should have a common base class. This eases the implementation of other features:

The class should support:

  • In a new thread, runon_start() once, and then body() many times, and then when should_stop() becomes true, run on_stop(), and join the thread.
  • get_tid()
  • request_stop() triggers should_stop().
  • set_name() trims the name to 15 chars (important!) and calls pthread_setname_np()

The reviewer should verify:

  • The code of managed_thread is clean, followable, documented inline, and well-named.
  • Likewise for Threadloop, ZED, audio_pipeline, and Switchboard.
  • The documentation for plugin-authors is updated.

Note to developers: @charmoniumQ has already started this, but I haven't finished, and it's worth creating a new draft off of the new master.

  • Write a new common/managed_thread.hpp based on this draft with the following changes:
    • Don't use InitProtocol. InitProtocol would simplify creation and joining without a start() and stop(), but I think it's not worth the added complexity.
    • The draft uses inheritance and virtual to define on_start(), body(), and on_stop(). This current version (in master) takes a function as a parameter to the constructor (std:function<void()>). We should go back to doing what master does, except it should be std::function<void(ManagedThread&)>, so that it can call thread.sleep and other methods.
  • Use in common/threadloop.hpp (switch from std::thread to ManagedThread).
  • Use in zed/src/main.cpp
  • Use in audio_pipeline
  • Use in common/switchboard.hpp
  • Use in common/*_logger.hpp.
@charmoniumQ charmoniumQ self-assigned this Jan 24, 2021
@charmoniumQ charmoniumQ added the plumbing Something that connects/interfaces/plugs into many parts of ILLIXR. label Jan 26, 2021
@charmoniumQ charmoniumQ mentioned this issue Feb 8, 2021
4 tasks
@e3m3 e3m3 added this to Backlog in ILLIXR improvements Mar 17, 2021
@charmoniumQ charmoniumQ moved this from Backlog to In progress in ILLIXR improvements Mar 17, 2021
@charmoniumQ charmoniumQ changed the title Base threadloop off of managed_thread Base threadloop off of ManagedThread Mar 22, 2021
@e3m3 e3m3 moved this from In progress to Backlog in ILLIXR improvements Mar 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plumbing Something that connects/interfaces/plugs into many parts of ILLIXR.
Projects
ILLIXR improvements
  
Issue Backlog
Development

No branches or pull requests

2 participants