-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Extend format patterns %T and %I to support native threads #3323
Comments
The simplest way to add support for native threads would be to extend Message::init() and look for native thread attributes when Thread::current() returned nullptr. However, inspecting native thread attributes is going to be OS dependent, just like Thread uses multiple implementations of ThreadImpl depending on the target platform. A cleaner way would be to split ThreadImpl in 3 parts:
For simplicity sake, NativeThreadImpl could provide stubbed methods for setStackSize and start, since they make no sense for already running threads. Instead of deriving from ThreadImpl, a Thread would contain a NativeThreadImpl (or a ThreadImpl when it is created by Thread constructor). |
There is pull request #3017 that also introduces patterns for native threads. |
The proposals made in pull request #3017 add a new pattern for the OS specific thread id.
Corresponding pull request #3333 |
Given that there are multiple proposals for the OS-native thread id (%O in #3017) and %I in the existing pattern, which direction do you intend to take in r1.12.0 ? |
|
%J is ok for the OS thread id (gettid()). |
PatternFormatter provides %T and %I to print the thread name and thread id. Those patterns depend on attributes of Message which are set in the init() function, using Thread::current() and calling getName() and getTid() on the thread if any.
Since Thread::current() works only for a thread that has been created using Poco::Thread, it does not work for threads that were created in another library (eg. std::thread).
The text was updated successfully, but these errors were encountered: