chans

package
v0.3.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Copyright 2023 The acquirecloud Authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsOpened

func IsOpened[V any](ch chan V) bool

IsOpened checks the channel ch and returns true if it is still opened. The function may consume value from the channel if any, and it will be lost.

func WriteToManyWithControl

func WriteToManyWithControl[V any](chnsDescs []WriteDesc[V], v V) (int, bool)

WriteToManyWithControl tries to write to many channels with control channels (WriteDesc). The value v will be written to only one channel and its index will be returned. The WriteDesc.DoneChan cannot read anything, but be closed. If the WriteDesc.DoneChan is closed, the second return param will be false. If the value is written the second param will be true.

Types

type WriteDesc

type WriteDesc[T any] struct {
	// DonceChan is the done indicator. The channel can be used to interrupt the function
	// for indicating that the WrtChan should not be used for write
	DoneChan <-chan struct{}
	// WrtChan is the channel where a write operation attempt should be made
	WrtChan chan<- T
}

WriteDesc is used by WriteToManyWithControl to describe write channels

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL