Threading Building Blocks (TBB) for Qt

I am building a CD ripper application in C++ and Qt. I would like to parallelize the application such that multiple tracks can be encoded concurrently. Therefore, I have structured the application in such a way that encoding a track is a "Task", and I'm working on a mechanism to run some number of these Tasks concurrently. I could, of course, accomplish this using threads and write my own Task queue or work manager, but I thought Intel's Threading Building Blocks (TBB) might be a better tool for the job. I have a couple of questions, however.

  • Is encoding a WAV file into a FLAC, Ogg Vorbis, or Mp3 file something that would work well as a tbb::task? The tutorial document states that "if threads block frequently, there is a performance loss when using the task scheduler". I don't think my encoding tasks would block for mutexes frequently, but the will need to access disk relatively frequently, since they must read the WAV data from disk in order to encode. Is this level of disk activity problematic in the sense described by the tutorial?
  • Does TBB work well with Qt? When using Qt threads, you can use Qt's signals/slots mechanism transparently across threads. Would the same be true if I were using tbb::tasks instead of Qt threads? Would there be any other "gotchas"?
  • Thanks for any insights you can provide.


    TBB is suppose to work well, even transparently, with other threading mechanisms so theoretically there should be nothing preventing you from using QT's thread classes in the same program. If there is something that works more naturally with QT threads, like the GUI, use them and keep the TBB stuff segregated as best you can or want.

    I don't see that you are making the best use of TBB as you currently outlined your design. You parallelize at the grossest level, the file. As you suspect, since the CD is a pretty slow device, you may spend more time seeking back and forth for data from multiple files than you actually save.

    The real bang for the buck with TBB should involve exploiting whatever data and/or task parallelism there is in the transformation process. Can you, for instance, pull any block of bytes out of the stream and apply whatever transform to it independently of any part of the stream before or after? Are there multiple steps to the transform that can be parallelized?


    为什么不使用Qt并发?

    链接地址: http://www.djcxy.com/p/64510.html

    上一篇: LLVM究竟是什么?

    下一篇: 用于Qt的线程构建块(TBB)