summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josh@tailscale.com>2021-02-09 08:27:48 -0800
committerJason A. Donenfeld <Jason@zx2c4.com>2021-02-09 18:29:01 +0100
commitcae090d116d4aa61494f5951a9d6ab6902017dce (patch)
treef72226032b924d63e1505206fe0738c06f82de2b
parent465261310b55898c3f67809bd56d58442bca4554 (diff)
device: clarify device.state.state docs (again)
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
-rw-r--r--device/device.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/device/device.go b/device/device.go
index de479bc..586715e 100644
--- a/device/device.go
+++ b/device/device.go
@@ -24,8 +24,10 @@ type Device struct {
state struct {
// state holds the device's state. It is accessed atomically.
// Use the device.deviceState method to read it.
- // If state is not locked, state is the current state of the device.
- // If state is locked, state is the current state or intended future state of the device.
+ // device.deviceState does not acquire the mutex, so it captures only a snapshot.
+ // During state transitions, the state variable is updated before the device itself.
+ // The state is thus either the current state of the device or
+ // the intended future state of the device.
// For example, while executing a call to Up, state will be deviceStateUp.
// There is no guarantee that that intended future state of the device
// will become the actual state; Up can fail.