Open dadodasyra opened 1 week ago
You can use ThreadManager to inspect threads created directly by the main thread, which include lots of useful functions to do what you want. Assuming that the thread you're looking for was started directly by the main thread, anyway.
though @cli_set_process_title may be an answer
No, this doesn't work on individual threads.
pmmpthread could introduce a method to set thread name, but platforms like MacOS only allow a thread to change its own name, so it's a bit annoying to implement.
though @cli_set_process_title may be an answer
No, this doesn't work on individual threads.
Isn't @cli_set_process_title already used in PM by Console reader?
You can use ThreadManager to inspect threads created directly by the main thread, which include lots of useful functions to do what you want. Assuming that the thread you're looking for was started directly by the main thread, anyway.
I've seen it after my issue, it seems like I'm unable to get a PID from it (currentThreadId seems a long 64bit id), and, weirdly the getcurrentthread returns null for each threads in the ThreadManager.
though @cli_set_process_title may be an answer
No, this doesn't work on individual threads.
Isn't @cli_set_process_title already used in PM by Console reader?
ConsoleReader isn't a thread
getcurrentthread returns null for each threads in the ThreadManager.
Thread::getCurrentThreadId() returns the ID of the currently executing thread. It's static for a reason.
You should use this function: https://github.com/pmmp/ext-pmmpthread/blob/71cae13851a2ee9cc8558d6e5d0faf8c5bedb36d/stubs/Thread.stub.php#L159
Thread::getCurrentThreadId() returns the ID of the currently executing thread. It's static for a reason.
You should use this function: https://github.com/pmmp/ext-pmmpthread/blob/71cae13851a2ee9cc8558d6e5d0faf8c5bedb36d/stubs/Thread.stub.php#L159
Yes that's my bad I didn't saw it was static, but that's what I was saying, it returns very long ID that I don't really know what they stands for:
foreach (ThreadManager::getInstance()->getAll() as $thread) {
var_dump($thread->getThreadName());
var_dump($thread->getThreadId());
}
string(13) "AsyncWorker#0"
int(128002130183936)
string(36) "poggit\libasynql\mysqli connector #0"
int(128002115503872)
string(36) "poggit\libasynql\mysqli connector #1"
int(128001985480448)
string(16) "ProxyChildThread"
int(128001819805440)
string(15) "LogsChildThread"
int(128001807222528)
string(4) "RCON"
int(128001792542464)
string(11) "TebexThread"
int(128001779959552)
string(11) "TebexThread"
int(128001631061760)
string(6) "RakLib"
int(128001618478848)
After doing some digging it looks like pthread_self() isn't the same as the ID shown by htop. Still, this shouldn't be necessary anyway. What's needed is to implement pmmp/ext-pmmpthread#139.
Problem description
I'm having trouble debugging who's using 10MBps, I've narrowed down to a SPID (thread pid) but I'm unable to do anything with it because there's no way to know which threads it corresponds in PM.
Proposed solution
As already asked, yes there's issues with the fact that there's no cross platform way (according to Dylan, though @cli_set_process_title may be an answer ?). I think at least there should be a way to get an instance of every threads used in pocketmine through a plugin so we can dump IDs with this. Or even better an in-game Pocketmine command to dump every process ids for admins.
Alternative solutions that don't require API changes
Doesn't require any BC breaks