void readfile(data &dat, const string filename) { object first; ifstream file(filename.c_str()); int value, weight, count1, i = 1; file >> first.value; file >> first.weight; dat.push_back(first); count1 = dat[0].value; //cout << dat[0].value << " " << dat[0].weight << endl; while(i <= count1) { object curr; file >> value; file >> weight; curr.value = value; curr.weight = weight; dat.push_back(curr); //cout << dat[i].value << " " << dat[i].weight << endl; i++; } }
bool file_data_loader_work(data& d, FILE* fh, size_t block_size) { std::lock_guard<std::mutex> lock(work_mutex); uint8_t b; while(block_size!=0) { if (fread(&b, 1, 1, fh) == 0) { return true; } d.push_back(b); if(block_size != file_data_loader::nblock) { block_size--; } } return false; }