World Conquest Chronicles

World Conquest Chronicles

go-sync-utils, v1.1

The library that provides utility entities for syncing.

Sending to a channel without blocking even if the channel is busy.

Change Log

  • sending to a channel without blocking even if the channel is busy;
  • adding the package comment.

Features

  • utility entities for the sync.WaitGroup type:
    • interface of the sync.WaitGroup type;
    • operating with a set of such interfaces as a whole;
  • sending to a channel without blocking even if the channel is busy.

Examples

syncutils.UnboundedSend:

package main

import (
    "fmt"

    syncutils "github.com/thewizardplusplus/go-sync-utils"
)

func main() {
    numbers := make(chan int, 2)
    for number := 0; number < 10; number++ {
        syncutils.UnboundedSend(numbers, number)
    }

    for index := 0; index < 10; index++ {
        number := <-numbers
        fmt.Println(number)
    }

    // Unordered output:
    // 0
    // 1
    // 2
    // 3
    // 4
    // 5
    // 6
    // 7
    // 8
    // 9
}

Repository

Link: https://github.com/thewizardplusplus/go-sync-utils/tree/v1.1.

Content: code.

License: MIT.