@@ -109,7 +109,7 @@ TextStreamReader::TextStreamReader(TextStreamInfo info)
109109
110110void TextStreamReader::onChunkUpdate (const std::string &text) {
111111 {
112- std::lock_guard <std::mutex> lock (mutex_);
112+ const std::scoped_lock <std::mutex> lock (mutex_);
113113 if (closed_)
114114 return ;
115115 queue_.push_back (text);
@@ -120,7 +120,7 @@ void TextStreamReader::onChunkUpdate(const std::string &text) {
120120void TextStreamReader::onStreamClose (
121121 const std::map<std::string, std::string> &trailer_attrs) {
122122 {
123- std::lock_guard <std::mutex> lock (mutex_);
123+ const std::scoped_lock <std::mutex> lock (mutex_);
124124 for (const auto &kv : trailer_attrs) {
125125 info_.attributes [kv.first ] = kv.second ;
126126 }
@@ -154,7 +154,7 @@ ByteStreamReader::ByteStreamReader(ByteStreamInfo info)
154154
155155void ByteStreamReader::onChunkUpdate (const std::vector<std::uint8_t > &bytes) {
156156 {
157- std::lock_guard <std::mutex> lock (mutex_);
157+ const std::scoped_lock <std::mutex> lock (mutex_);
158158 if (closed_)
159159 return ;
160160 queue_.push_back (bytes);
@@ -165,7 +165,7 @@ void ByteStreamReader::onChunkUpdate(const std::vector<std::uint8_t> &bytes) {
165165void ByteStreamReader::onStreamClose (
166166 const std::map<std::string, std::string> &trailer_attrs) {
167167 {
168- std::lock_guard <std::mutex> lock (mutex_);
168+ const std::scoped_lock <std::mutex> lock (mutex_);
169169 for (const auto &kv : trailer_attrs) {
170170 info_.attributes [kv.first ] = kv.second ;
171171 }
@@ -308,7 +308,7 @@ TextStreamWriter::TextStreamWriter(
308308}
309309
310310void TextStreamWriter::write (const std::string &text) {
311- std::lock_guard <std::mutex> lock (write_mutex_);
311+ const std::scoped_lock <std::mutex> lock (write_mutex_);
312312 if (closed_)
313313 throw std::runtime_error (" Cannot write to closed TextStreamWriter" );
314314
@@ -339,7 +339,7 @@ ByteStreamWriter::ByteStreamWriter(
339339}
340340
341341void ByteStreamWriter::write (const std::vector<std::uint8_t > &data) {
342- std::lock_guard <std::mutex> lock (write_mutex_);
342+ const std::scoped_lock <std::mutex> lock (write_mutex_);
343343 if (closed_)
344344 throw std::runtime_error (" Cannot write to closed ByteStreamWriter" );
345345
0 commit comments