github.com/euank/go@v0.0.0-20160829210321-495514729181/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  // Semrelease atomically increments *s and notifies a waiting goroutine
    17  // if one is blocked in Semacquire.
    18  // It is intended as a simple wakeup primitive for use by the synchronization
    19  // library and should not be used directly.
    20  func runtime_Semrelease(s *uint32)
    21  
    22  // Approximation of notifyList in runtime/sema.go. Size and alignment must
    23  // agree.
    24  type notifyList struct {
    25  	wait   uint32
    26  	notify uint32
    27  	lock   uintptr
    28  	head   unsafe.Pointer
    29  	tail   unsafe.Pointer
    30  }
    31  
    32  // See runtime/sema.go for documentation.
    33  func runtime_notifyListAdd(l *notifyList) uint32
    34  
    35  // See runtime/sema.go for documentation.
    36  func runtime_notifyListWait(l *notifyList, t uint32)
    37  
    38  // See runtime/sema.go for documentation.
    39  func runtime_notifyListNotifyAll(l *notifyList)
    40  
    41  // See runtime/sema.go for documentation.
    42  func runtime_notifyListNotifyOne(l *notifyList)
    43  
    44  // Ensure that sync and runtime agree on size of notifyList.
    45  func runtime_notifyListCheck(size uintptr)
    46  func init() {
    47  	var n notifyList
    48  	runtime_notifyListCheck(unsafe.Sizeof(n))
    49  }
    50  
    51  // Active spinning runtime support.
    52  // runtime_canSpin returns true is spinning makes sense at the moment.
    53  func runtime_canSpin(i int) bool
    54  
    55  // runtime_doSpin does active spinning.
    56  func runtime_doSpin()