github.com/likebike/go--@v0.0.0-20190911215757-0bd925d16e96/go/src/sync/runtime.go (about)

     1  // Copyright 2012 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package sync
     6  
     7  import "unsafe"
     8  
     9  // defined in package runtime
    10  
    11  // Semacquire waits until *s > 0 and then atomically decrements it.
    12  // It is intended as a simple sleep primitive for use by the synchronization
    13  // library and should not be used directly.
    14  func runtime_Semacquire(s *uint32)
    15  
    16  // SemacquireMutex is like Semacquire, but for profiling contended Mutexes.
    17  // If lifo is true, queue waiter at the head of wait queue.
    18  func runtime_SemacquireMutex(s *uint32, lifo bool)
    19  
    20  // Semrelease atomically increments *s and notifies a waiting goroutine
    21  // if one is blocked in Semacquire.
    22  // It is intended as a simple wakeup primitive for use by the synchronization
    23  // library and should not be used directly.
    24  // If handoff is true, pass count directly to the first waiter.
    25  func runtime_Semrelease(s *uint32, handoff bool)
    26  
    27  // Approximation of notifyList in runtime/sema.go. Size and alignment must
    28  // agree.
    29  type notifyList struct {
    30  	wait   uint32
    31  	notify uint32
    32  	lock   uintptr
    33  	head   unsafe.Pointer
    34  	tail   unsafe.Pointer
    35  }
    36  
    37  // See runtime/sema.go for documentation.
    38  func runtime_notifyListAdd(l *notifyList) uint32
    39  
    40  // See runtime/sema.go for documentation.
    41  func runtime_notifyListWait(l *notifyList, t uint32)
    42  
    43  // See runtime/sema.go for documentation.
    44  func runtime_notifyListNotifyAll(l *notifyList)
    45  
    46  // See runtime/sema.go for documentation.
    47  func runtime_notifyListNotifyOne(l *notifyList)
    48  
    49  // Ensure that sync and runtime agree on size of notifyList.
    50  func runtime_notifyListCheck(size uintptr)
    51  func init() {
    52  	var n notifyList
    53  	runtime_notifyListCheck(unsafe.Sizeof(n))
    54  }
    55  
    56  // Active spinning runtime support.
    57  // runtime_canSpin returns true is spinning makes sense at the moment.
    58  func runtime_canSpin(i int) bool
    59  
    60  // runtime_doSpin does active spinning.
    61  func runtime_doSpin()
    62  
    63  func runtime_nanotime() int64