diff --git a/partitioning/fast_clustering_t.cpp b/partitioning/fast_clustering_t.cpp index 50f4f32da96ca05c7e0892e68f6edcc066ca19ee..93e6ad94571cf82e09e27550dc16b9548d221597 100755 --- a/partitioning/fast_clustering_t.cpp +++ b/partitioning/fast_clustering_t.cpp @@ -127,19 +127,22 @@ void process_file_part(const std::string& input_filename, int part_id, int start } // lock the mutex for this output file until the end of this loop iteration - std::lock_guard<std::mutex> lock(output_mutexes[cluster_id]); - + //std::lock_guard<std::mutex> lock(output_mutexes[cluster_id]); + output_mutexes[cluster_id].lock(); // write the sequence and its id to a cluster file corresponding to the bases found after the primer std::ofstream output_file(output_dir + "/" + cluster_id + ".fasta", std::ios::app); // ios app is to append to the file if (!output_file.is_open()) { std::cerr << "Error opening output file\n"; - return; + output_mutexes[cluster_id].unlock(); + continue; } output_file << ">" << read_name << "\n" << sequence << "\n"; // output format is fasta output_file.close(); + output_mutexes[cluster_id].unlock(); } input_read_file.close(); + // end the timer and print the elapsed time auto end = std::chrono::high_resolution_clock::now(); std::chrono::duration<double> elapsed = end - start;