+
+void
+Encoder::writer_thread ()
+{
+ while (1)
+ {
+ boost::mutex::scoped_lock lock (_writer_mutex);
+ TIMING ("writer sleeps with a queue of %1", _write_queue.size());
+ while (_write_queue.empty() && !_terminate_writer) {
+ _writer_condition.wait (lock);
+ }
+ TIMING ("writer wakes with a queue of %1", _write_queue.size());
+
+ if (_terminate_writer) {
+ return;
+ }
+
+ pair<boost::shared_ptr<EncodedData>, int> encoded = _write_queue.front ();
+ _write_queue.pop_front ();
+
+ lock.unlock ();
+ encoded.first->write (_opt, encoded.second);
+ lock.lock ();
+ }
+}