Project

General

Profile

« Previous | Next » 

Revision f6c21781

Added by David Sorber over 9 years ago

Well I fixed my bizzarre problem last night. It turns out that I was building the argv list for each forked process from the main input file list instead of from the sub list passed to each thread. Now PCA runs in a much more stable fashion. Next I'd like to add some sort of progress reporting and also decompress support. I had the idea of using inotify on the output files (since their names are known a priori) however inotify is Linux only and I haven't yet found a drop in replacement for Mac OS.

View differences:

software/photo_compress_archiver/PhotoCompressArchiver.cc
#include <chrono>
#include <iostream>
#include <iterator> // temporary for std::distance
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
#include "PhotoCompressArchiver.hh"
#include "packjpglib.h"
#define OUT(x) {\
std::lock_guard<std::mutex> lock(m_output_mutex);\
x\
......
}
OUT(std::cout << " Total compressed bytes: " << m_total_compressed_size
<< "\n" << std::endl;)
<< std::endl;)
// Calculate and display ratio
double ratio = (double)m_total_compressed_size / m_total_uncompressed_size;
OUT(std::cout << " Compression ratio: " << ratio << "\n" << std::endl;)
OUT(std::cout << "execute terminating" << std::endl;)
......
<< std::endl;)
}
#endif
uint32_t argv_size = file_sublist->size() + 5;
const char **exec_argv = new const char* [argv_size];
......
exec_argv[3] = PROG_OPT3;
// Add the sublist files to the argv array
uint32_t idx = 3;
for (auto& image_path : m_file_list)
uint32_t idx = 4;
for (auto& image_path : *file_sublist)
{
exec_argv[idx++] = image_path.string().c_str();
}
......
int rc = stat(new_file.c_str(), &statbuf);
if (rc)
{
OUT(std::cerr << "ERROR: unable to stat file " << new_file << std::endl;)
OUT(std::cerr << "T[" << tid << "] ERROR: unable to stat file "
<< new_file << std::endl;)
}
m_total_compressed_size += statbuf.st_size;
}

Also available in: Unified diff