| 225 | } |
| 226 | |
| 227 | bool DataFeed::PickOneFile(std::string* filename) { |
| 228 | PADDLE_ENFORCE_NOT_NULL( |
| 229 | mutex_for_pick_file_, |
| 230 | common::errors::PreconditionNotMet( |
| 231 | "You should call SetFileListMutex before PickOneFile")); |
| 232 | PADDLE_ENFORCE_NOT_NULL( |
| 233 | file_idx_, |
| 234 | common::errors::PreconditionNotMet( |
| 235 | "You should call SetFileListIndex before PickOneFile")); |
| 236 | std::unique_lock<std::mutex> lock(*mutex_for_pick_file_); |
| 237 | VLOG(4) << "filelist_ size: " << filelist_.size(); |
| 238 | if (*file_idx_ == filelist_.size()) { |
| 239 | VLOG(3) << "DataFeed::PickOneFile no more file to pick"; |
| 240 | return false; |
| 241 | } |
| 242 | VLOG(3) << "file_idx_=" << *file_idx_; |
| 243 | *filename = filelist_[(*file_idx_)++]; |
| 244 | return true; |
| 245 | } |
| 246 | |
| 247 | void DataFeed::CheckInit() { |
| 248 | PADDLE_ENFORCE_EQ( |
no test coverage detected