Getting information from a TThread

Hi all,

I have a macro that uses the TThread class to iterate over a few TTrees in parallel. I monitor the status of the threads and print them on the screen during the process.

I would like to be able to also print how far in the iteration of the TTree each thread is. Is there a way to extract information from the handler of the thread for such a thing?

I hope that my request was clearly explained.

Thanks for your help,
Sergio

Hi Sergio,

I am not quite sure I understand, is your question on TTree, i.e. figuring out inside the thread handler the iteration status of the processed tree? If you can post your macro, that would help understand the problem better.

Cheers,
Jakob

Hi Jakob,

Thanks for your reply. What I mean is that inside the thread handler I have the information of the iteration status and I would like to send it “outside” the thread so I can print it while monitoring the threads.

I just thought that what I could do is have a global variable (probably a vector) where each thread modifies an entry that I can then access from “outside”. If there is something prettier it would be nice but for now I will just do that.

Cheers,
Sergio

I see, so you’d then have one “slot” per thread in the vector and every thread would only access the element index that corresponds to its thread number? That would prevent the threads from stepping on each others toes. There would still be a race between the outside watcher and the thread handler, i.e. updating as well as reading the status values would need to be locked by a mutex. If your iteration status is just an integer, you can avoid the mutex by using an std::atomic

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.