Source file src/sync/runtime.go

     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  // Semacquire(RW)Mutex(R) is like Semacquire, but for profiling contended
    17  // Mutexes and RWMutexes.
    18  // If lifo is true, queue waiter at the head of wait queue.
    19  // skipframes is the number of frames to omit during tracing, counting from
    20  // runtime_SemacquireMutex's caller.
    21  // The different forms of this function just tell the runtime how to present
    22  // the reason for waiting in a backtrace, and is used to compute some metrics.
    23  // Otherwise they're functionally identical.
    24  func runtime_SemacquireMutex(s *uint32, lifo bool, skipframes int)
    25  func runtime_SemacquireRWMutexR(s *uint32, lifo bool, skipframes int)
    26  func runtime_SemacquireRWMutex(s *uint32, lifo bool, skipframes int)
    27  
    28  // Semrelease atomically increments *s and notifies a waiting goroutine
    29  // if one is blocked in Semacquire.
    30  // It is intended as a simple wakeup primitive for use by the synchronization
    31  // library and should not be used directly.
    32  // If handoff is true, pass count directly to the first waiter.
    33  // skipframes is the number of frames to omit during tracing, counting from
    34  // runtime_Semrelease's caller.
    35  func runtime_Semrelease(s *uint32, handoff bool, skipframes int)
    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 reports whether 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
    64  

View as plain text