//NewChannel spawns and returns a new channel sharing the underlying buffer.
424015
func (buf *SharedBuffer) NewChannel() SimpleChannel {
	ch := &sharedBufferChannel{
		in:  make(chan interface{}),
		out: make(chan interface{}),
		buf: queue.New(),
	}
	buf.in <- ch
	return ch
}
117088
func NewMockChannelProvider(ctx core.Providers) (*MockChannelProvider, error) {
	// Create a mock client with the mock channel
	cp := MockChannelProvider{
		ctx: ctx,
	}
	return &cp, nil
}
167131
func (h *handler) New() chan struct{} {
	// Lock the mutex.
	h.mutex.Lock()
	defer h.mutex.Unlock()

	// Signal the stop request by closing the channel if open.
	if !h.stopChanClosed {
		close(h.stopChan)
	}

	// Create a new stop channel.
	h.stopChan = make(chan struct{})

	// Update the flag.
	h.stopChanClosed = false

	return h.stopChan
}
557042
func NewPool(host Host, opts *ConnectOpts) (*Pool, error) {
	initialCap := opts.InitialCap
	if initialCap <= 0 {
		// Fallback to MaxIdle if InitialCap is zero, this should be removed
		// when MaxIdle is removed
		initialCap = opts.MaxIdle
	}

	maxOpen := opts.MaxOpen
	if maxOpen <= 0 {
		maxOpen = 2
	}

	p, err := pool.NewChannelPool(initialCap, maxOpen, func() (net.Conn, error) {
		conn, err := NewConnection(host.String(), opts)
		if err != nil {
			return nil, err
		}

		return conn, err
	})
	if err != nil {
		return nil, err
	}

	return &Pool{
		pool: p,
		host: host,
		opts: opts,
	}, nil
}
992094
func NewQueue(service *Service, workers uint) *Queue {
	// unbuffered channels
	q := &Queue{
		service:       service,
		notifications: make(chan notification),
		Responses:     make(chan Response),
	}
	// startup workers to send notifications
	for i := uint(0); i < workers; i++ {
		go worker(q)
	}
	return q
}
576960
func (c *remoteConn) OpenChannel(name string, data []byte) (ssh.Channel, error) {
	channel, _, err := c.sconn.OpenChannel(name, data)
	if err != nil {
		return nil, trace.Wrap(err)
	}

	return channel, nil
}
246415
func NewChannelHandler(channel LogPartsChannel) *ChannelHandler {
	handler := new(ChannelHandler)
	handler.SetChannel(channel)

	return handler
}
1162655
func newChannel(c *Connection, id uint16) *Channel {
	return &Channel{
		connection: c,
		id:         id,
		rpc:        make(chan message),
		consumers:  makeConsumers(),
		confirms:   newConfirms(),
		recv:       (*Channel).recvMethod,
		errors:     make(chan *Error, 1),
	}
}
684297
func createChannels(opts *Options) []wsstream.ChannelType {
	// open the requested channels, and always open the error channel
	channels := make([]wsstream.ChannelType, 5)
	channels[stdinChannel] = readChannel(opts.Stdin)
	channels[stdoutChannel] = writeChannel(opts.Stdout)
	channels[stderrChannel] = writeChannel(opts.Stderr)
	channels[errorChannel] = wsstream.WriteChannel
	channels[resizeChannel] = wsstream.ReadChannel
	return channels
}
1224226
func New(config fab.EndpointConfig, opts ...options.Opt) (*ChannelProvider, error) {
	return &ChannelProvider{
		ctxtCaches: lazycache.New(
			"Client_Context_Cache",
			func(key lazycache.Key) (interface{}, error) {
				ck := key.(*ctxtCacheKey)
				return newContextCache(ck.context, opts), nil
			},
		),
	}, nil
}
840459
func newBuffer() *buffer {
	e := new(element)
	b := &buffer{
		Cond: newCond(),
		head: e,
		tail: e,
	}
	return b
}
1116968
func NewIPChannel(client *TwilioIPMessagingClient, serviceSid string, friendlyName string, uniqueName string, public bool, attributes string) (*IPChannel, error) {
	var channel *IPChannel

	params := url.Values{}
	params.Set("FriendlyName", friendlyName)
	params.Set("UniqueName", uniqueName)
	kind := "private"
	if public {
		kind = "public"
	}
	params.Set("Type", kind)
	params.Set("Attributes", attributes)

	res, err := client.post(params, "/Services/"+serviceSid+"/Channels.json")

	if err != nil {
		return channel, err
	}

	channel = new(IPChannel)
	err = json.Unmarshal(res, channel)

	return channel, err
}
918449
func NewPointerChannelWrapper(pointerChan <-chan *WrappedPointer, errorChan <-chan error) *PointerChannelWrapper {
	return &PointerChannelWrapper{tools.NewBaseChannelWrapper(errorChan), pointerChan}
}
415014
func NewPlayer(sampleRate, channelNum, bitDepthInBytes, bufferSizeInBytes int) (*Player, error) {
	c, err := NewContext(sampleRate, channelNum, bitDepthInBytes, bufferSizeInBytes)
	if err != nil {
		return nil, err
	}
	return c.NewPlayer(), nil
}
1145708
func NewBuffer(f Format) *Buffer {
	return &Buffer{f: f, tmp: make([]byte, f.Width())}
}
1207657
func NewBuffer(name string, capacity int) *Buffer {
	b := &Buffer{
		buf:   make([]telegraf.Metric, capacity),
		first: 0,
		last:  0,
		size:  0,
		cap:   capacity,

		MetricsAdded: selfstat.Register(
			"write",
			"metrics_added",
			map[string]string{"output": name},
		),
		MetricsWritten: selfstat.Register(
			"write",
			"metrics_written",
			map[string]string{"output": name},
		),
		MetricsDropped: selfstat.Register(
			"write",
			"metrics_dropped",
			map[string]string{"output": name},
		),
		BufferSize: selfstat.Register(
			"write",
			"buffer_size",
			map[string]string{"output": name},
		),
		BufferLimit: selfstat.Register(
			"write",
			"buffer_limit",
			map[string]string{"output": name},
		),
	}
	b.BufferSize.Set(int64(0))
	b.BufferLimit.Set(int64(capacity))
	return b
}
28169
func NewMockChannel(channelID string) (*Channel, error) {

	ctx := &mockClientContext{
		Providers:       NewMockProviderContext(),
		SigningIdentity: mspmocks.NewMockSigningIdentity("user", "Org1MSP"),
	}

	// Set up mock channel service
	chProvider, err := NewMockChannelProvider(ctx)
	if err != nil {
		return nil, errors.WithMessage(err, "new mock channel provider failed")
	}
	channelService, err := chProvider.ChannelService(ctx, channelID)
	if err != nil {
		return nil, errors.WithMessage(err, "failed to create mock channel service")
	}

	peer := NewMockPeer("Peer1", "example.com")

	channelService.(*MockChannelService).SetDiscovery(NewMockDiscoveryService(nil, peer))
	channelService.(*MockChannelService).SetSelection(NewMockSelectionService(nil, peer))

	channel := &Channel{
		Client:         ctx,
		channelService: channelService,
		channelID:      channelID,
	}

	return channel, nil
}