Skip to content
This repository was archived by the owner on May 3, 2026. It is now read-only.

Commit 0c9e913

Browse files
liam-tealeion098
andauthored
simplify port_mutex_unlock_all
Co-authored-by: ion098 <146852218+ion098@users.noreply.github.com>
1 parent e2c2785 commit 0c9e913

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/system/system_daemon.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ static void port_mutex_lock_all() {
6767
*
6868
*/
6969
static void port_mutex_unlock_all() {
70-
// this looks weird because of how std::unlock is implemented. See unlock_ports for details.
71-
constexpr auto num_ports = std::tuple_size<decltype(zest::Brain::ports)>::value;
72-
unlock_ports(std::make_index_sequence<num_ports>{});
70+
[]<size_t... Is>(std::index_sequence<Is...>) {
71+
// unlock mutexes in reverse order of locking
72+
(zest::Brain::ports[sizeof...(Is) - 1 - Is].mutex.unlock(), ...);
73+
}(std::make_index_sequence<zest::Brain::ports.size()>{});
7374
}
7475

7576
static void _disabled_task(void*);

0 commit comments

Comments
 (0)