[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>;
diff --git a/platform/api/udp_socket.h b/platform/api/udp_socket.h
index 0bc8aff..e668db1 100644
--- a/platform/api/udp_socket.h
+++ b/platform/api/udp_socket.h
@@ -5,11 +5,10 @@
#ifndef PLATFORM_API_UDP_SOCKET_H_
#define PLATFORM_API_UDP_SOCKET_H_
-#include <atomic>
-#include <cstdint>
-#include <functional>
+#include <stddef.h> // size_t
+#include <stdint.h> // uint8_t
+
#include <memory>
-#include <mutex>
#include "platform/api/network_interface.h"
#include "platform/base/error.h"
@@ -19,7 +18,6 @@
namespace openscreen {
class TaskRunner;
-class UdpSocket;
// An open UDP socket for sending/receiving datagrams to/from either specific
// endpoints or over IP multicast.