[Open Screen] Update documentation on threading, other fixes.
- Adds document on threading assumptions.
- Clarifies assumptions in task_runner.h.
- Other misc documentation updates.
Change-Id: Ie3635c6f4f84ea4fdfb44790ec585d358452bfe3
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/2037961
Commit-Queue: mark a. foltz <mfoltz@chromium.org>
Reviewed-by: Ryan Keane <rwkeane@google.com>
Reviewed-by: Yuri Wiitala <miu@chromium.org>
diff --git a/platform/api/task_runner.h b/platform/api/task_runner.h
index b10e5ec..6297c21 100644
--- a/platform/api/task_runner.h
+++ b/platform/api/task_runner.h
@@ -14,11 +14,12 @@
// A thread-safe API surface that allows for posting tasks. The underlying
// implementation may be single or multi-threaded, and all complication should
-// be handled by the implementation class. It is the expectation of this API
-// that the underlying impl gives the following guarantees:
+// be handled by the implementation class. The implementation must guarantee:
// (1) Tasks shall not overlap in time/CPU.
// (2) Tasks shall run sequentially, e.g. posting task A then B implies
// that A shall run before B.
+// (3) If task A is posted before task B, then any mutation in A happens-before
+// B runs (even if A and B run on different threads).
class TaskRunner {
public:
using Task = std::packaged_task<void() noexcept>;