简体   繁体   中英

Synchronizing threads and signalling

I am trying to tell one thread that it's ok to continue with calculations after the other thread reads data from a named pipe. Currently, I have a while infinite loop which checks everytime for new data. But this is inefficient as it consumes 100% of the CPU...

My question is... Is there any way to wait until one thread has checked for new data and tell the other thread that it's ok to continue (something like a signal)?

There are various solutions for your problem:

  • Signals and slots model of Qt
  • C++: Boost.Signals2 or Boost.Signals (deprecated)
  • C++: libsigc++ - template-based
  • C++: sigslot
  • C++: XLObject - template-based, Qt-oriented.
  • C++: Signals
  • C: libevent - multi-threaded, platformindependent
  • C: libev - minimal alternative to libevent.

Have a look at them and find the one that fits the best for you.

Qt拥有您想要的一切,QThread可与信号和插槽配合使用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM