Sure. The variable boost::mutex phase_mut_ is a private member of the
class 'recorder' as are several functions such as the one I quoted above,
private:
// some other private members
bool shutdown_;
boost::uint32_t headers_to_finish_;
boost::mutex phase_mut_;
std::vector<thread_p> stream_threads_;
void enter_headers_phase(bool phase_locked) {
if (phase_locked) {
boost::mutex::scoped_lock lock(phase_mut_);
headers_to_finish_++;
}
}
void leave_headers_phase(bool phase_locked) {
if (phase_locked) {
boost::mutex::scoped_lock lock(phase_mut_);
headers_to_finish_--;
lock.unlock();
ready_for_streaming_.notify_all();
}
}
// etc.
In the constructor, a thread is spawned that calls some of these
functions. Here is the constructor (abbreviated):
class recording {
public:
recording(const std::string &filename, const
std::vector<lsl::stream_info> &streams, const std::vector<std::string>
&watchfor, bool collect_offsets=true) :
offsets_enabled_(collect_offsets), unsorted_(false), shutdown_(false),
streamid_(0), streaming_to_finish_(0), headers_to_finish_(0) {
// blah blah blah
// create a recording thread for each stream
for (std::size_t k=0;k<streams.size();k++)
stream_threads_.push_back(thread_p(newboost::thread(&recording::record_from_streaminfo,this,streams[k],true)));
// blah blah blah
}
This function record_from_streaminfo then callsenter_headers_phase with
the boolean true as the argument:
void record_from_streaminfo(lsl::stream_info src, bool phase_locked) {
// blah blah blah
// --- headers phase
try {
enter_headers_phase(phase_locked);
}
// blah blah blah
}
At this point the application is doing its recording and everything is
great.
>
> {
> boost::mutex::scoped_lock lock(phase_mut_);
> shutdown_ = true;
> }
>
> while on the destructor?
Here is the destructor (also abbreviated , but the mutex lock is the
very first thing that happens):
~recording() {
try {
// set the shutdown flag (from now on no more new streams)
{
boost::mutex::scoped_lock lock(phase_mut_);
shutdown_ = true;
}
// etc. etc.
}
Thanks for taking a look at this. This is a terrible way to have to look
at code, so I really appreciate any time spent.