aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/sync/export_test.go
blob: ffbe56746406288ae48cda2173346ed0b7f25d2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package sync

// Export for testing.
var Runtime_Semacquire = runtime_Semacquire
var Runtime_Semrelease = runtime_Semrelease
var Runtime_procPin = runtime_procPin
var Runtime_procUnpin = runtime_procUnpin

// poolDequeue testing.
type PoolDequeue interface {
	PushHead(val interface{}) bool
	PopHead() (interface{}, bool)
	PopTail() (interface{}, bool)
}

func NewPoolDequeue(n int) PoolDequeue {
	d := &poolDequeue{
		vals: make([]eface, n),
	}
	// For testing purposes, set the head and tail indexes close
	// to wrapping around.
	d.headTail = d.pack(1<<dequeueBits-500, 1<<dequeueBits-500)
	return d
}

func (d *poolDequeue) PushHead(val interface{}) bool {
	return d.pushHead(val)
}

func (d *poolDequeue) PopHead() (interface{}, bool) {
	return d.popHead()
}

func (d *poolDequeue) PopTail() (interface{}, bool) {
	return d.popTail()
}

func NewPoolChain() PoolDequeue {
	return new(poolChain)
}

func (c *poolChain) PushHead(val interface{}) bool {
	c.pushHead(val)
	return true
}

func (c *poolChain) PopHead() (interface{}, bool) {
	return c.popHead()
}

func (c *poolChain) PopTail() (interface{}, bool) {
	return c.popTail()
}