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

Add thread name support #3659

Closed
JackyWoo opened this issue Jul 5, 2022 · 5 comments
Closed

Add thread name support #3659

JackyWoo opened this issue Jul 5, 2022 · 5 comments

Comments

@JackyWoo
Copy link
Contributor

JackyWoo commented Jul 5, 2022

Poco is really a wonderful lib that I use it in my project. Thank you.

I have some questions about Thread.

  1. Why current method return 0 when it is main thread, it will cause user confusion
  2. Why setName method does not really set thread name.

Expecting your responses

@aleks-f
Copy link
Member

aleks-f commented Jul 5, 2022

  1. because main thread is not a Poco::Thread
  2. I'm not understanding the question
    void Thread::setName(const std::string& name)
    {
    FastMutex::ScopedLock lock(_mutex);
    _name = name;
    }

@JackyWoo
Copy link
Contributor Author

JackyWoo commented Jul 5, 2022

@aleks-f thanks for reply.

Why setName method does not really set thread name.

For example use pthread_set_name_np, prctl.

In my case I want get thread name through ps command.

@aleks-f
Copy link
Member

aleks-f commented Jul 5, 2022

That can be added, you can send a pull. However, keep in mind that all ThreadImpls must then have setName implemented (no-op implementations are ok, since we have the _name to fall back to).

Here's a strange way to set it on Windows: https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2015/debugger/how-to-set-a-thread-name-in-native-code

@JackyWoo
Copy link
Contributor Author

JackyWoo commented Jul 5, 2022

ok

@aleks-f aleks-f added feature and removed question labels Jul 5, 2022
@aleks-f aleks-f added this to the Release 1.13.0 milestone Jul 5, 2022
@aleks-f
Copy link
Member

aleks-f commented Jul 6, 2022

somewhat related #3384

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants