summaryrefslogtreecommitdiffhomepage
path: root/pkg/state/map.go
diff options
context:
space:
mode:
authorAdin Scannell <ascannell@google.com>2019-10-31 18:02:04 -0700
committergVisor bot <gvisor-bot@google.com>2019-10-31 18:03:24 -0700
commita99d3479a84ca86843e500dbdf58db0af389b536 (patch)
tree4bce14ea740020ee2652a6a874517550174d1f34 /pkg/state/map.go
parent36837c4ad3f3c840791379db81d02b60d918c0f5 (diff)
Add context to state.
PiperOrigin-RevId: 277840416
Diffstat (limited to 'pkg/state/map.go')
-rw-r--r--pkg/state/map.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/pkg/state/map.go b/pkg/state/map.go
index 7e6fefed4..4f3ebb0da 100644
--- a/pkg/state/map.go
+++ b/pkg/state/map.go
@@ -15,6 +15,7 @@
package state
import (
+ "context"
"fmt"
"reflect"
"sort"
@@ -219,3 +220,13 @@ func (m Map) AfterLoad(fn func()) {
// data dependencies have been cleared.
m.os.callbacks = append(m.os.callbacks, fn)
}
+
+// Context returns the current context object.
+func (m Map) Context() context.Context {
+ if m.es != nil {
+ return m.es.ctx
+ } else if m.ds != nil {
+ return m.ds.ctx
+ }
+ return context.Background() // No context.
+}