Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Franco_M_
Beginner
54 Views

Ideas on asynchronous infinite loop

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
54 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

Franco_M_
Beginner
54 Views

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

Is there an easier way of achieving this? 

Thank you!

Nikita_P_Intel
Employee
54 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

Reply