File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,23 @@ private:
5050 LogicalTime released_time_;
5151 Scheduler* scheduler_;
5252
53+ /*
54+ * Note that we use the main scheduler lock to protect our `released_time_`
55+ * variable. We cannot use a local mutex here that only protects our local
56+ * state. This is, because we also need to use a lock to wait on a condition
57+ * variable. This lock must be the same lock as the one that is used when
58+ * updating the wait condition. (See "An atomic predicate" in
59+ * https://www.modernescpp.com/index.php/c-core-guidelines-be-aware-of-the-traps-of-condition-variables)
60+ *
61+ * Here we have two conditions in which we want to stop the wait:
62+ * 1. When the tag that we are waiting for was released.
63+ * 2. When the given function `abort_waiting` returns true. In a typical usage
64+ * scenario, this would be the case when a new event was scheduled.
65+ *
66+ * We need to make sure that both conditions are updated while holding the
67+ * lock that we use for waiting on the condition variable. Our only option for
68+ * this is to use the global scheduler lock.
69+ */
5370public:
5471 LogicalTimeBarrier (Scheduler* scheduler)
5572 : scheduler_(scheduler) {}
You can’t perform that action at this time.
0 commit comments