summaryrefslogtreecommitdiffhomepage
path: root/runsc/specutils
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2020-05-28 14:45:52 -0700
committergVisor bot <gvisor-bot@google.com>2020-05-28 14:49:06 -0700
commitf7418e21590e271302a3c375323950c209ce5ced (patch)
tree856411630ca41d2ccc56888d464aa8d24e2c4ebd /runsc/specutils
parent7b79370c105b28a1cffa2d12d81898fc6b278728 (diff)
Move Cleanup to its own package
PiperOrigin-RevId: 313663382
Diffstat (limited to 'runsc/specutils')
-rw-r--r--runsc/specutils/specutils.go30
1 files changed, 0 insertions, 30 deletions
diff --git a/runsc/specutils/specutils.go b/runsc/specutils/specutils.go
index 837d5e238..f1fa573c5 100644
--- a/runsc/specutils/specutils.go
+++ b/runsc/specutils/specutils.go
@@ -444,36 +444,6 @@ func ContainsStr(strs []string, str string) bool {
return false
}
-// Cleanup allows defers to be aborted when cleanup needs to happen
-// conditionally. Usage:
-// c := MakeCleanup(func() { f.Close() })
-// defer c.Clean() // any failure before release is called will close the file.
-// ...
-// c.Release() // on success, aborts closing the file and return it.
-// return f
-type Cleanup struct {
- clean func()
-}
-
-// MakeCleanup creates a new Cleanup object.
-func MakeCleanup(f func()) Cleanup {
- return Cleanup{clean: f}
-}
-
-// Clean calls the cleanup function.
-func (c *Cleanup) Clean() {
- if c.clean != nil {
- c.clean()
- c.clean = nil
- }
-}
-
-// Release releases the cleanup from its duties, i.e. cleanup function is not
-// called after this point.
-func (c *Cleanup) Release() {
- c.clean = nil
-}
-
// RetryEintr retries the function until an error different than EINTR is
// returned.
func RetryEintr(f func() (uintptr, uintptr, error)) (uintptr, uintptr, error) {