Skip to content

Commit db9a288

Browse files
committed
minor: Monitor._read optimization
1 parent 7cfc61f commit db9a288

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/monitor.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,25 +121,22 @@ class BridgeMonitor: public Stream {
121121

122122
if (size == 0) return;
123123

124-
k_mutex_lock(&monitor_mutex, K_FOREVER);
125-
126124
MsgPack::arr_t<uint8_t> message;
127125
bool ret = bridge->call(MON_READ_METHOD, size).result(message);
128126

129127
if (ret) {
128+
k_mutex_lock(&monitor_mutex, K_FOREVER);
130129
for (size_t i = 0; i < message.size(); ++i) {
131130
temp_buffer.store_char(static_cast<char>(message[i]));
132131
}
132+
k_mutex_unlock(&monitor_mutex);
133133
}
134134

135135
// if (bridge.lastError.code > NO_ERR) {
136136
// is_connected = false;
137137
// }
138-
139-
k_mutex_unlock(&monitor_mutex);
140138
}
141139

142-
143140
};
144141

145142
extern BridgeClass Bridge;

0 commit comments

Comments
 (0)