예제 #1
0
 void open_next_file(stream_type& res) {
   if(files_open_ >= concurrent_files_)
     return;
   while(paths_cur_ != paths_end_) {
     std::string path = *paths_cur_;
     ++paths_cur_;
     res.reset(new file_stream(path.c_str(), *this));
     if(res->good())
       return;
     res.reset();
     throw std::runtime_error(err::msg() << "Can't open file '" << path << "'");
   }
 }
예제 #2
0
 void open_next_pipe(stream_type& res) {
   while(!free_pipes_.empty()) {
     const char* path = free_pipes_.front();
     free_pipes_.pop_front();
     res.reset(new pipe_stream(path, *this));
     if(res->good()) {
       busy_pipes_.insert(path);
       return;
     }
     // The pipe failed to open, so it is not marked as busy. This
     // reset will make us forget about this path.
     res.reset();
   }
 }