Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

Ideas on asynchronous infinite loop

Franco_M_
Beginner
503 Views

Hello,

I have an idea that I'd like to implement, but I don't know where to start.

The class I intend to write is a disk intensive task one, so I'd like to have its users submit data to be written to disk, and return immediately before the actual disk operation. I believe this could be done with this:

  • concurrent_queue will be used to submit data to be written, the function will enqueue and exit immediately
  • parallel_do or similar construct that monitors the queue and does the hard work
  • the infinite loop should, I believe, run a separate thread

I don't think what I've written corresponds to the best implementation, or it suits TBB the best.

Do you have any suggestions?

Thank you!
    Franco

0 Kudos
3 Replies
Nikita_P_Intel
Employee
503 Views

Hi Franco!

Your idea is similar that we have in fgbzip2 example. This Flow Graph example uses async_node to read/write file asynchronously.

Thanks,

Nikita

0 Kudos
Franco_M_
Beginner
503 Views

Thanks, Nikita. I find it really cool, but probably more complicated than needed. 

Is there an easier way of achieving this? 

Thank you!

0 Kudos
Nikita_P_Intel
Employee
503 Views

I suppose that concurrent queue with infinite thread is the easiest way to achieve what you want.

You could also try this approach, but it is a little bit more complex.

Nikita

0 Kudos
Reply