First of all I apologize if it gets too long, as the problem can be detailed quickly, however, I describe a good part of the environment to perhaps come and help.
I'm developing a tool in C++ that analyzes genomic data (FASTQ data specifically). In case you don't know, a FASTQ file contains raw reads of genetic sequence, where each set of 4 lines of this file represents a read of the genome. Well, as the processing of a read does not depend on other reads (in my case), I intend to parallelize the work with threads to save processing time.
When searching, I found some libraries ready and I'm trying to adapt. Right now I'm trying to use Thread Pool (specifically this lib -> https://github.com/log4cplus/ThreadPool/) but I'm having some problems with the integration.
I will detail the general algorithm a little. Each iteration in the FASTQ file takes a set of 4 lines from the file and stores it in this struct.
struct READ {
std::string name; // Small size
std::string comment; // Small size
std::string seq; // String ranging between 0 and 1000 characters
std::string which; // The same amount of 'seq' characters
};
That is immediately passed as a value to the foreign function to perform the (non-trivial) task managed by the Thread Pool.
ThreadPool pool (4); // Creating thread pool with 4 threads
while (exist_read) // as long as there are reads to be processed -> read set of 4 lines
{
Read read;
read = next_read (); // read will contain 4 lines of the file read in the iteration
pool.enqueue ([read] {
Search (read); // search function performs non-trivial search work
});
}
As can be seen, I passed the values in the lambda function and tested it with several threads, but I ended up having inferior performance when using single-thread. So I was suggested to use a movable object. And with great help, I got this struct.
struct READ
{
READ () = default;
READ (READ &&) = default;
READ & operator = (READ &&) = default;
std::string name;
std::string comment;
std::string seq;
std::string which;
};
And the lambda function has changed to:
pool.enqueue ([r {std::move(read)}] {
Search (std::move(r));
});
In addition, did update the reading of the FASTQ file of:
[...]
Read read;
read.name = lines[0];
read.seq = lines[1];
read.comment = lines[2];
read.qual = lines[3];
[...]
To:
[...]
Read read;
read.name = std::move(lines [0]);
read.seq = std::move(lines [1]);
read.comment = std::move(lines [2]);
read.qual = std::move(lines [3]);
[...]
However, I still haven't been able to test the performance, because I'm having the following print_error
error: function "READ::READ (const READ &)" (declared implicitly) cannot be referenced - it is a deleted function C / C ++ (1776)
I searched other forums but I couldn't find an answer that would suit my problem. If anyone can help me with this problem I will be very grateful. I hope I have been clear. In addition, I also accept suggestions for other alternatives.
Thanks.