const std::pair<uint64_t, uint64_t> p = _session.progress();
assert(p.first <= p.second);
- setValue(p.first);
- setMaximum(p.second);
-
- const QString err = _session.error();
- if (!err.isEmpty()) {
- show_error();
+ if (p.second) {
+ setValue(p.first);
+ setMaximum(p.second);
+ } else {
+ const QString err = _session.error();
+ if (!err.isEmpty())
+ show_error();
close();
}
-
- if (p.first == p.second)
- close();
}
} // dialogs
pair<uint64_t, uint64_t> StoreSession::progress() const
{
- lock_guard<mutex> lock(_mutex);
- return make_pair(_units_stored, _unit_count);
+ return make_pair(_units_stored.load(), _unit_count.load());
}
const QString& StoreSession::error() const
const int unit_size = snapshot->unit_size();
assert(unit_size != 0);
- {
- lock_guard<mutex> lock(_mutex);
- _unit_count = snapshot->get_sample_count();
- }
+ _unit_count = snapshot->get_sample_count();
const unsigned int samples_per_block = BlockSize / unit_size;
progress_updated();
const uint64_t end_sample = min(
- start_sample + samples_per_block, _unit_count);
+ start_sample + samples_per_block, _unit_count.load());
snapshot->get_samples(data, start_sample, end_sample);
if(sr_session_append(_file_name.c_str(), data, unit_size,
}
start_sample = end_sample;
-
- {
- lock_guard<mutex> lock(_mutex);
- _units_stored = start_sample;
- }
+ _units_stored = start_sample;
}
+ _unit_count = 0;
progress_updated();
delete[] data;
std::atomic<bool> _interrupt;
+ std::atomic<uint64_t> _units_stored, _unit_count;
+
mutable std::mutex _mutex;
- uint64_t _units_stored;
- uint64_t _unit_count;
QString _error;
};