PDA

View Full Version : Threads and slots



cafu
11th March 2010, 17:30
Hi to all,

I have a mess in my head(and almost sure iin my code as well), i have around 6 working thread that push information to a controller thread using signal slot(QueuedConnection). the thread are similar just read info from different devices, so the signals are the same prototype. the signals from this thread are connected to single slot in the controller. the controller uses mutx in this slots cause critical data. my question is what happen with the signals in the mean time the controller thread is working on the analisis of the info from one of the working threads.

The signals are emmited really often.

squidge
11th March 2010, 19:03
The signals are queued until your threads handle them. Signals and slots are thread safe.

cafu
15th March 2010, 09:20
Thanks, i got it to work as i wanted, i was using to many threads with no reason, but this clear my mind

cafu
15th March 2010, 09:55
One more Question how can i Know if i am creating to many threads? even if they work properly together, at leat aparently

franz
16th March 2010, 06:52
You have too many threads when
# you loose overview
# scheduling overhead slows the application down

When having tasks that need to be done, I always prefer a thread pool (threads handling scheduled tasks).

There's a pretty decent article on having too many threads and task based programming at http://www.codeguru.com/cpp/misc/misc/threadsprocesses/article.php/c13533