mirror of
https://github.com/tbnobody/OpenDTU.git
synced 2025-12-13 02:09:58 +01:00
logging: unlock while processing buffer
allows high priority tasks to log another message while the buffer is being processed.
This commit is contained in:
committed by
Thomas Basler
parent
c106224052
commit
b2e91401b7
@@ -200,7 +200,7 @@ void MessageOutputClass::send_ws_chunk(const uint8_t* buffer, size_t size)
|
|||||||
|
|
||||||
void MessageOutputClass::loop()
|
void MessageOutputClass::loop()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(_msgLock);
|
std::unique_lock<std::mutex> lock(_msgLock);
|
||||||
|
|
||||||
while (_buffer_out != _buffer_in) {
|
while (_buffer_out != _buffer_in) {
|
||||||
uint8_t msg_len = static_cast<uint8_t>(_buffer[_buffer_out]);
|
uint8_t msg_len = static_cast<uint8_t>(_buffer[_buffer_out]);
|
||||||
@@ -212,11 +212,16 @@ void MessageOutputClass::loop()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lock.unlock();
|
||||||
|
taskYIELD(); // allow high priority tasks to log while we process the buffer
|
||||||
|
|
||||||
auto msg_start = reinterpret_cast<const uint8_t*>(&_buffer[_buffer_out]) + 1;
|
auto msg_start = reinterpret_cast<const uint8_t*>(&_buffer[_buffer_out]) + 1;
|
||||||
serialWrite(msg_start, msg_len);
|
serialWrite(msg_start, msg_len);
|
||||||
Syslog.write(msg_start, msg_len);
|
Syslog.write(msg_start, msg_len);
|
||||||
send_ws_chunk(msg_start, msg_len);
|
send_ws_chunk(msg_start, msg_len);
|
||||||
|
|
||||||
|
lock.lock();
|
||||||
|
|
||||||
_buffer_out += 1 + msg_len;
|
_buffer_out += 1 + msg_len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user