You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Set thread names #222: While POSIX supports threadnames, they can only be 15 chars, which is quite restrictive. This class can support arbitrary string names. When we have advanced logging (Fix CPU timing infrastructure #208), the full name can be used from this class.
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).
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:
on_start()
once, and thenbody()
many times, and then whenshould_stop()
becomes true, runon_stop()
, and join the thread.get_tid()
request_stop()
triggersshould_stop()
.set_name()
trims the name to 15 chars (important!) and callspthread_setname_np()
The reviewer should verify:
managed_thread
is clean, followable, documented inline, and well-named.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
.common/managed_thread.hpp
based on this draft with the following changes:InitProtocol
.InitProtocol
would simplify creation and joining without astart()
andstop()
, but I think it's not worth the added complexity.virtual
to defineon_start()
,body()
, andon_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 bestd::function<void(ManagedThread&)>
, so that it can callthread.sleep
and other methods.common/threadloop.hpp
(switch fromstd::thread
toManagedThread
).zed/src/main.cpp
common/switchboard.hpp
common/*_logger.hpp
.The text was updated successfully, but these errors were encountered: