func MarkIdle(c net.Conn) error {
	if cn, ok := c.(*conn); ok {
		cn.markIdle()
		return nil
	}
	return errNotManaged
}
MarkIdle marks the given connection as being idle, and therefore eligible for
closing at any time. The passed connection must have been returned by a call
to Accept from this listener.
package listener
import (
	"errors"
	"net"
	"runtime"
	"sync"
	"sync/atomic"
)
type mode int8
const (
	Manual mode = iota
	Automatic
	Deadline
)
func Wrap(l net.Listener, m mode) *T {
	t := &T{
		l:    l,
		mode: m,
		shards: make([]shard, 2*runtime.NumCPU()),
	}
	for i := range t.shards {
		t.shards[i].init(t)
	}
	return t
}
type T struct {
	mu sync.Mutex
	l  net.Listener
	connCount uint64
	shards    []shard
	mode mode
}
var _ net.Listener = &T{}
func (t *T) Accept() (net.Conn, error) {
	c, err := t.l.Accept()
	if err != nil {
		return nil, err
	}
	connID := atomic.AddUint64(&t.connCount, 1)
	shard := &t.shards[int(connID)%len(t.shards)]
	wc := &conn{
		Conn:  c,
		shard: shard,
		mode:  t.mode,
	}
	if err = wc.init(); err != nil {
		return nil, err
	}
	return wc, nil
}
func (t *T) Addr() net.Addr {
	return t.l.Addr()
}
func (t *T) Close() error {
	return t.l.Close()
}
func (t *T) CloseIdle() error {
	for i := range t.shards {
		t.shards[i].closeConns(false, false)
	}
	return nil
}
func (t *T) Drain() error {
	for i := range t.shards {
		t.shards[i].closeConns(false, true)
	}
	for i := range t.shards {
		t.shards[i].wait()
	}
	return nil
}
func (t *T) DrainAll() error {
	for i := range t.shards {
		t.shards[i].closeConns(true, true)
	}
	for i := range t.shards {
		t.shards[i].wait()
	}
	return nil
}
var errNotManaged = errors.New("listener: passed net.Conn is not managed by this package")
func Disown(c net.Conn) error {
	if cn, ok := c.(*conn); ok {
		return cn.disown()
	}
	return errNotManaged
}