Project

General

Profile

« Previous | Next » 

Revision 3eeb1485

Added by David Sorber over 9 years ago

Moved things around so that the main thread breaks off pieces of work and hands them to the threads. This version has less than half the runtime of the previous version for the Photos library test set!

View differences:

software/photo_compress_archiver/PhotoCompressArchiver.hh
#include <atomic>
#include <condition_variable>
#include <cstdint>
#include <deque>
#include <mutex>
#include <string>
#include <thread>
......
const boost::regex JPEG_REGEX("^.+\\.(jpg)|(jpeg)$", boost::regex::icase);
const boost::regex PJG_REGEX("^.+\\.pjg$", boost::regex::icase);
struct work_unit_t {
std::vector<const char*> exec_argv;
std::vector<std::string*> output_filenames;
};
typedef struct work_unit_t WorkUnit;
class PhotoCompressArchiver
{
public:
......
/**
* Fork and wait
*/
void fork_worker(uint32_t tid, std::vector<bfs::path>* file_sublist);
void fork_worker(uint32_t tid);
/**
* Calculate the return the "global" percent done as determined by the
......
std::thread* p_finder_thread; // file finder thread
std::vector<std::thread*> m_worker_threads; // worker threads
std::deque<WorkUnit*> m_work_unit_queue;
std::mutex m_work_unit_mtx;
std::condition_variable m_work_unit_cv;
bool m_filter_empty; // is the filter regex empty
boost::regex& m_filter_regex; // filter regular expression
};

Also available in: Unified diff