Q:

How to keep data for progress bar

My program downloads files from servers, and parse it.
For download files i have got a bar, but i want to make bar for parsing.
Parsing take a lot of time, and power, so my solution dont have to use a lot of power.
few servers -> few files -> line in file
I.e in one time, i download files from servers (about 4-5 files) and when downloaded, just start parsing.
But when servers is more than 1, my program download files from two servers so i have 2x more files. Files name on servers are the same but when i download file, i change name of these files to "world"+"orginalfile.txt"
I thought about something like that:
map<int server,std::map<int file(<make it enum),{current line, max lines} >> (struktura)
Because when reading file, i want to make emit to send data to window.
When start reading i want to send (file,lines_in_file,server)
And when reading send (file,current_line,world)
Then in window which read this data push this data to some variable (like above example) and run second function to calculate progress bar.
i.e

servers[] -> files [] -> thread download -> thread reading (these
  threads start per file, so if servers are 2 and files 4 these threads
  start 8x) -> emit init signal (send file,lines_in_file,server_number)
  + emit (currentLineWhenReading,file,server)  signal when reading line-per-line

So how to make it the best, to get a lot of data and hold it + use litte power to calculate this ?

A:

Parse in a separate thread. Increment (with mutex) some counter while parsing (or use some atomic increment), like e.g. in this answer.
Probably the parsing thread is mostly IO bound. So it will most often wait for disk IO. In that case, the small overhead of mutex locking is insignificant.
In the main GUI thread, set up things (e.g. some Qt timer...) to read every second the parse counter (with mutex), and update the progress bar

