syncex

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	QSize = 64
)

Variables

This section is empty.

Functions

func Collect added in v0.0.3

func Collect(errchans ...<-chan error) <-chan error
Example
doWork := func(url string) chan error {
	errs := make(chan error)
	go func(url string) {
		// Some expensive work..
		_, err := http.Get(url)
		if err != nil {
			errs <- err
		}
	}(url)
	return errs
}

for err := range Collect(
	doWork("1"),
	doWork("2"),
) {
	if err != nil {
		fmt.Println("Error:", err)
	}
}
Output:

func CollectContext added in v0.0.3

func CollectContext(ctx context.Context, errchans ...<-chan error) <-chan error

Types

type Counter added in v0.0.4

type Counter struct {
	// contains filtered or unexported fields
}

func (*Counter) Add added in v0.0.4

func (c *Counter) Add(delta int64)

func (*Counter) Dec added in v0.0.4

func (c *Counter) Dec()

func (*Counter) Inc added in v0.0.4

func (c *Counter) Inc()

func (*Counter) Reset added in v0.0.4

func (c *Counter) Reset()

func (*Counter) Value added in v0.0.4

func (c *Counter) Value() int64

type Semaphore

type Semaphore struct {
	// contains filtered or unexported fields
}

func NewSemaphore

func NewSemaphore(initialCount int) *Semaphore

func (*Semaphore) Acquire

func (s *Semaphore) Acquire()

func (*Semaphore) AcquireTimeout

func (s *Semaphore) AcquireTimeout(timeout time.Duration) bool

func (*Semaphore) Release

func (s *Semaphore) Release()

type UnboundedChan added in v0.0.6

type UnboundedChan struct {

	// Q      *gxqueue.Queue
	Q *deque.Deque
	// contains filtered or unexported fields
}

refer from redisgo/redis/pool.go

func NewUnboundedChan added in v0.0.6

func NewUnboundedChan() *UnboundedChan

func (*UnboundedChan) Close added in v0.0.6

func (q *UnboundedChan) Close()

func (*UnboundedChan) Len added in v0.0.6

func (q *UnboundedChan) Len() int

func (*UnboundedChan) Pop added in v0.0.6

func (q *UnboundedChan) Pop() interface{}

func (*UnboundedChan) Push added in v0.0.6

func (q *UnboundedChan) Push(v interface{})

func (*UnboundedChan) SetWaitOption added in v0.0.6

func (q *UnboundedChan) SetWaitOption(wait bool)

在pop时,如果没有资源,是否等待 即使用乐观锁还是悲观锁

func (*UnboundedChan) TryPop added in v0.0.6

func (q *UnboundedChan) TryPop() (interface{}, bool)

Jump to

Keyboard shortcuts

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