Skip to content

Commit 8861451

Browse files
authored
Removing code duplication in SerialDispatcher. (#13)
1 parent 8edd5b9 commit 8861451

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

src/serial/SerialDispatcher.cpp

+1-19
Original file line numberDiff line numberDiff line change
@@ -122,25 +122,7 @@ void SerialDispatcher::flush()
122122

123123
size_t SerialDispatcher::write(uint8_t const b)
124124
{
125-
mbed::ScopedLock<rtos::Mutex> lock(_mutex);
126-
127-
auto iter = findThreadCustomerDataById(rtos::ThisThread::get_id());
128-
129-
/* If this thread hasn't registered yet
130-
* with the SerialDispatcher via 'begin'.
131-
*/
132-
if (iter == std::end(_thread_customer_list))
133-
return 0;
134-
135-
if (iter->tx_buffer.availableForStore())
136-
iter->tx_buffer.store_char(b);
137-
138-
/* Inform the worker thread that new data has
139-
* been written to a Serial transmit buffer.
140-
*/
141-
_cond.notify_one();
142-
143-
return 1;
125+
return write(&b, 1);
144126
}
145127

146128
size_t SerialDispatcher::write(const uint8_t * data, size_t len)

0 commit comments

Comments
 (0)