github.com/primecitizens/pcz/std@v0.2.1/builtin/go/lock.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  //
     4  // Copyright 2009 The Go Authors. All rights reserved.
     5  // Use of this source code is governed by a BSD-style
     6  // license that can be found in the LICENSE file.
     7  
     8  package stdgo
     9  
    10  // Mutual exclusion locks.  In the uncontended case,
    11  // as fast as spin locks (just a few user-level instructions),
    12  // but on the contention path they sleep in the kernel.
    13  // A zeroed Mutex is unlocked (no need to initialize each lock).
    14  // Initialization is helpful for static lock ranking, but not required.
    15  type Mutex struct {
    16  	// Empty struct if lock ranking is disabled, otherwise includes the lock rank
    17  	lockRankStruct
    18  	// Futex-based impl treats it as uint32 key,
    19  	// while sema-based impl as M* waitm.
    20  	// Used to be a union, but unions break precise GC.
    21  	key uintptr
    22  }
    23  
    24  // lockRankStruct is embedded in mutex, but is empty when staticklockranking is
    25  // disabled (the default)
    26  type lockRankStruct struct{}