github.com/c12o16h1/go/src@v0.0.0-20200114212001-5a151c0f00ed/sync/export_test.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 // Export for testing. 8 var Runtime_Semacquire = runtime_Semacquire 9 var Runtime_Semrelease = runtime_Semrelease 10 var Runtime_procPin = runtime_procPin 11 var Runtime_procUnpin = runtime_procUnpin 12 13 // poolDequeue testing. 14 type PoolDequeue interface { 15 PushHead(val interface{}) bool 16 PopHead() (interface{}, bool) 17 PopTail() (interface{}, bool) 18 } 19 20 func NewPoolDequeue(n int) PoolDequeue { 21 d := &poolDequeue{ 22 vals: make([]eface, n), 23 } 24 // For testing purposes, set the head and tail indexes close 25 // to wrapping around. 26 d.headTail = d.pack(1<<dequeueBits-500, 1<<dequeueBits-500) 27 return d 28 } 29 30 func (d *poolDequeue) PushHead(val interface{}) bool { 31 return d.pushHead(val) 32 } 33 34 func (d *poolDequeue) PopHead() (interface{}, bool) { 35 return d.popHead() 36 } 37 38 func (d *poolDequeue) PopTail() (interface{}, bool) { 39 return d.popTail() 40 } 41 42 func NewPoolChain() PoolDequeue { 43 return new(poolChain) 44 } 45 46 func (c *poolChain) PushHead(val interface{}) bool { 47 c.pushHead(val) 48 return true 49 } 50 51 func (c *poolChain) PopHead() (interface{}, bool) { 52 return c.popHead() 53 } 54 55 func (c *poolChain) PopTail() (interface{}, bool) { 56 return c.popTail() 57 }