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 5package sync 6 7// Export for testing. 8var Runtime_Semacquire = runtime_Semacquire 9var Runtime_Semrelease = runtime_Semrelease 10var Runtime_procPin = runtime_procPin 11var Runtime_procUnpin = runtime_procUnpin 12 13// poolDequeue testing. 14type PoolDequeue interface { 15 PushHead(val any) bool 16 PopHead() (any, bool) 17 PopTail() (any, bool) 18} 19 20func 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 30func (d *poolDequeue) PushHead(val any) bool { 31 return d.pushHead(val) 32} 33 34func (d *poolDequeue) PopHead() (any, bool) { 35 return d.popHead() 36} 37 38func (d *poolDequeue) PopTail() (any, bool) { 39 return d.popTail() 40} 41 42func NewPoolChain() PoolDequeue { 43 return new(poolChain) 44} 45 46func (c *poolChain) PushHead(val any) bool { 47 c.pushHead(val) 48 return true 49} 50 51func (c *poolChain) PopHead() (any, bool) { 52 return c.popHead() 53} 54 55func (c *poolChain) PopTail() (any, bool) { 56 return c.popTail() 57} 58