1 // Copyright 2020 The gVisor Authors.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file.
5 6 package sync
7 8 import (
9 "sync"
10 )
11 12 // Aliases of standard library types.
13 type (
14 // Cond is an alias of sync.Cond.
15 Cond = sync.Cond
16 17 // Locker is an alias of sync.Locker.
18 Locker = sync.Locker
19 20 // Once is an alias of sync.Once.
21 Once = sync.Once
22 23 // Pool is an alias of sync.Pool.
24 Pool = sync.Pool
25 26 // WaitGroup is an alias of sync.WaitGroup.
27 WaitGroup = sync.WaitGroup
28 29 // Map is an alias of sync.Map.
30 Map = sync.Map
31 )
32 33 // NewCond is a wrapper around sync.NewCond.
34 func NewCond(l Locker) *Cond {
35 return sync.NewCond(l)
36 }
37 38 // OnceFunc is a wrapper around sync.OnceFunc.
39 func OnceFunc(f func()) func() {
40 return sync.OnceFunc(f)
41 }
42 43 // OnceValue is a wrapper around sync.OnceValue.
44 func OnceValue[T any](f func() T) func() T {
45 return sync.OnceValue(f)
46 }
47 48 // OnceValues is a wrapper around sync.OnceValues.
49 func OnceValues[T1, T2 any](f func() (T1, T2)) func() (T1, T2) {
50 return sync.OnceValues(f)
51 }
52