Debian Codegraph @

pkg/util/flowcontrol/fairqueuing/promise/interface.go

raw
1 /*
2 Copyright 2019 The Kubernetes Authors.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 package promise
18
19 // WriteOnce represents a variable that is initially not set and can
20 // be set once and is readable. This is the common meaning for
21 // "promise".
22 type WriteOnce interface {
23 // Get reads the current value of this variable. If this
24 // variable is not set yet then this call blocks until this
25 // variable gets a value.
26 Get() interface{}
27
28 // Set normally writes a value into this variable, unblocks every
29 // goroutine waiting for this variable to have a value, and
30 // returns true. In the unhappy case that this variable is
31 // already set, this method returns false without modifying the
32 // variable's value.
33 Set(interface{}) bool
34 }