c++ - Blocking read from FIFO via ifstream object -


I open a FIFA file as ifstream . As soon as the object is created, till I send nothing to the FIFO, the thread is blocked (which is right for me). Then I call the getline () to get the data from the stream.

How will I read the thread again until more information is written in the FIFO file?

Thank you

I have not tested this code but I am thinking Whether FIFA is bus when you read all the available data then setting the EOF bit. In that case, you may be able to:

  std :: ifstream FIFO; Std :: string line; Bool done = false; / * Open your FIFO code * / while ((done!)) While (std :: getline (FIFO, line)) {/ * do stuff with line} /} if (FIFO.) ({Fifo.clear ()); // Enable EOF bit to enable more reading} else {done = true; }}  

If you read the end of Fifo, then reset and wait for further data. If there has been an error, you have done I got the idea for this. You have to close FIFA in the same block and open it again, where you reset.


Comments