Skip to content

Commit 97e82ce

Browse files
committed
doc: Add note about Waiter::m_mutex and interaction with the EventLoop::m_mutex
1 parent 81d58f5 commit 97e82ce

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

include/mp/proxy-io.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,13 @@ struct Waiter
298298
});
299299
}
300300

301+
//! Mutex mainly used internally by waiter class, but also used externally
302+
//! to guard access to related state. Specifically, since the thread_local
303+
//! ThreadContext struct owns a Waiter, the Waiter::m_mutex is used to guard
304+
//! access to other parts of the struct to avoid needing to deal with more
305+
//! mutexes than necessary. This mutex can be held at the same time as
306+
//! EventLoop::m_mutex as long as Waiter::mutex is locked first and
307+
//! EventLoop::m_mutex is locked second.
301308
std::mutex m_mutex;
302309
std::condition_variable m_cv;
303310
std::optional<kj::Function<void()>> m_fn;

0 commit comments

Comments
 (0)